lib/css_parser.rb in css_parser-1.2.4 vs lib/css_parser.rb in css_parser-1.2.5
- old
+ new
@@ -6,11 +6,11 @@
require 'zlib'
require 'stringio'
require 'iconv'
module CssParser
- VERSION = '1.2.4'
+ VERSION = '1.2.5'
# Merge multiple CSS RuleSets by cascading according to the CSS 2.1 cascading rules
# (http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order).
#
# Takes one or more RuleSet objects.
@@ -76,11 +76,13 @@
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 not properties.has_key?(property)
properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
- elsif is_important and not properties[property][:is_important]
- properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
+ elsif is_important
+ if not properties[property][:is_important] or properties[property][:specificity] <= specificity
+ properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
+ end
elsif properties[property][:specificity] < specificity or properties[property][:specificity] == specificity
unless properties[property][:is_important]
properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
end
end