lib/css_parser.rb in css_parser-1.20.0 vs lib/css_parser.rb in css_parser-1.21.0
- old
+ new
@@ -55,11 +55,11 @@
@folded_declaration_cache = {}
# in case called like CssParser.merge([rule_set, rule_set])
rule_sets.flatten! if rule_sets[0].is_a?(Array)
- unless rule_sets.all? { |rs| rs.is_a?(CssParser::RuleSet) }
+ unless rule_sets.all?(CssParser::RuleSet)
raise ArgumentError, 'all parameters must be CssParser::RuleSets.'
end
return rule_sets[0] if rule_sets.length == 1
@@ -68,11 +68,11 @@
rule_sets.each do |rule_set|
rule_set.expand_shorthand!
specificity = rule_set.specificity
- specificity ||= rule_set.selectors.map { |s| calculate_specificity(s) }.compact.max || 0
+ specificity ||= rule_set.selectors.filter_map { |s| calculate_specificity(s) }.max || 0
rule_set.each_declaration do |property, value, is_important|
# Add the property to the list to be folded per http://www.w3.org/TR/CSS21/cascade.html#cascading-order
if !properties.key?(property)
properties[property] = {value: value, specificity: specificity, is_important: is_important}
@@ -136,10 +136,10 @@
base_uri = Addressable::URI.parse(base_uri) unless base_uri.is_a?(Addressable::URI)
css.gsub(URI_RX) do
uri = Regexp.last_match(1).to_s.gsub(/["']+/, '')
# Don't process URLs that are already absolute
- unless uri.match(%r{^[a-z]+://}i)
+ unless uri.match?(%r{^[a-z]+://}i)
begin
uri = base_uri.join(uri)
rescue
nil
end