Permalink
Browse files

Multiple selectors should properly calculate specificity -- closes GH-28

  • Loading branch information...
alexdunae committed Apr 24, 2012
1 parent 9a82e13 commit a0c9c96fa3a0ac65cd2f7ac95d5a109cbd2b3f92
Showing with 5 additions and 4 deletions.
  1. +3 −2 lib/css_parser.rb
  2. +2 −2 test/test_merging.rb
View
@@ -24,8 +24,9 @@ module CssParser
# If no specificity is explicitly set and the RuleSet has *one* selector,
# the specificity is calculated using that selector.
#
- # If no selectors or multiple selectors are present, the specificity is
- # treated as 0.
+ # If no selectors the specificity is treated as 0.
+ #
+ # If multiple selectors are present then the greatest specificity is used.
#
# ==== Example #1
# rs1 = RuleSet.new(nil, 'color: black;')
View
@@ -46,11 +46,11 @@ def test_merging_multiple
assert_equal '5px;', merged['margin']
end
- def test_multiple_selectors_should_have_zero_specificity
+ def test_multiple_selectors_should_have_proper_specificity
rs1 = RuleSet.new('p, a[rel="external"]', 'color: black;')
rs2 = RuleSet.new('a', 'color: blue;')
merged = CssParser.merge(rs1, rs2)
- assert_equal 'blue;', merged['color']
+ assert_equal 'black;', merged['color']
end
def test_setting_specificity

0 comments on commit a0c9c96

Please sign in to comment.