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 +4 -4
- data/lib/css_parser/parser.rb +2 -2
- data/lib/css_parser/rule_set.rb +6 -3
- data/lib/css_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebc43b9f09241b83ffe9a2878e0a2e5295c79f6d2e02bb20dcaf54d376f91e58
|
4
|
+
data.tar.gz: 5b29858923af894f1b84251c59de6a4638ae0929b63ac0b432a7607d9dd32111
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd7a00f2be5a2ddbf730eb115dbc0e15f9ac7a71ac92e1a056161a2b418e01d7abeb757c6f8d5fabafd9e4f7dba034b209ca571012ee44ee6b377b2e4bd8100f
|
7
|
+
data.tar.gz: ac8aeba706f1ae35126c6d5c4a150a52862af8654f1342e6c5b36ebce8c0b71c26e0d0931d09081b3b01a70685c3d2b173031a3e1ff32a8477799c3e39e013e4
|
data/lib/css_parser/parser.rb
CHANGED
@@ -448,7 +448,7 @@ module CssParser
|
|
448
448
|
current_media_query << token << ' '
|
449
449
|
end
|
450
450
|
end
|
451
|
-
elsif in_charset or
|
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? &&
|
470
|
+
rule_start = start_offset if options[:capture_offsets] && rule_start.nil? && /^[^\s]+$/.match?(token)
|
471
471
|
end
|
472
472
|
end
|
473
473
|
|
data/lib/css_parser/rule_set.rb
CHANGED
@@ -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
|
-
|
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}"
|
data/lib/css_parser/version.rb
CHANGED
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.
|
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:
|
11
|
+
date: 2025-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|