css_parser 1.21.0 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8880ebd6978e8a8a3108ea93b4d567252aee152b28f237dab31809f1488f42e
4
- data.tar.gz: 4e8379acf246b7fe2573a2ada4fc49c01e9c3b2de43fe80d07f42390f8f16450
3
+ metadata.gz: ebc43b9f09241b83ffe9a2878e0a2e5295c79f6d2e02bb20dcaf54d376f91e58
4
+ data.tar.gz: 5b29858923af894f1b84251c59de6a4638ae0929b63ac0b432a7607d9dd32111
5
5
  SHA512:
6
- metadata.gz: 480947bb06a6c40ab955f76ff9eb7ba9ac5caf160d7fe343d16901e9f37210c9ccab22a07a4d3165ec26bec4cd28547f530718978d2d969ed398c8195351a0c0
7
- data.tar.gz: e7a757c9dc096e71d5f617343f0900bacddea42bef4b26ca68f2830728a480ace908807dc4db82b6b0b77a11c1b2c9295ad814bb2aaa80fd069c959cd58afe65
6
+ metadata.gz: fd7a00f2be5a2ddbf730eb115dbc0e15f9ac7a71ac92e1a056161a2b418e01d7abeb757c6f8d5fabafd9e4f7dba034b209ca571012ee44ee6b377b2e4bd8100f
7
+ data.tar.gz: ac8aeba706f1ae35126c6d5c4a150a52862af8654f1342e6c5b36ebce8c0b71c26e0d0931d09081b3b01a70685c3d2b173031a3e1ff32a8477799c3e39e013e4
@@ -448,7 +448,7 @@ module CssParser
448
448
  current_media_query << token << ' '
449
449
  end
450
450
  end
451
- elsif in_charset or token =~ /@charset/i
451
+ elsif in_charset or /@charset/i.match?(token)
452
452
  # iterate until we are out of the charset declaration
453
453
  in_charset = !token.include?(';')
454
454
  elsif !in_string && token.include?('}')
@@ -467,7 +467,7 @@ module CssParser
467
467
  current_selectors << token
468
468
 
469
469
  # mark this as the beginning of the selector unless we have already marked it
470
- rule_start = start_offset if options[:capture_offsets] && rule_start.nil? && token =~ /^[^\s]+$/
470
+ rule_start = start_offset if options[:capture_offsets] && rule_start.nil? && /^[^\s]+$/.match?(token)
471
471
  end
472
472
  end
473
473
 
@@ -89,17 +89,20 @@ module CssParser
89
89
  # puts declarations['margin']
90
90
  # => #<CssParser::RuleSet::Declarations::Value:0x00000000030c1838 @important=true, @order=2, @value="0px auto">
91
91
  #
92
- # If the property already exists its value will be over-written.
92
+ # If the property already exists its value will be over-written unless it was !important and the new value
93
+ # is not !important.
93
94
  # If the value is empty - property will be deleted
94
95
  def []=(property, value)
95
96
  property = normalize_property(property)
97
+ currently_important = declarations[property]&.important
96
98
 
97
- if value.is_a?(Value)
99
+ if value.is_a?(Value) && (!currently_important || value.important)
98
100
  declarations[property] = value
99
101
  elsif value.to_s.strip.empty?
100
102
  delete property
101
103
  else
102
- declarations[property] = Value.new(value)
104
+ value = Value.new(value)
105
+ declarations[property] = value if !currently_important || value.important
103
106
  end
104
107
  rescue ArgumentError => e
105
108
  raise e.exception, "#{property} #{e.message}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CssParser
4
- VERSION = '1.21.0'.freeze
4
+ VERSION = '1.21.1'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.0
4
+ version: 1.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-13 00:00:00.000000000 Z
11
+ date: 2025-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable