css_parser 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/css_parser.rb CHANGED
@@ -8,7 +8,7 @@ require 'stringio'
8
8
  require 'iconv'
9
9
 
10
10
  module CssParser
11
- VERSION = '1.2.0'
11
+ VERSION = '1.2.2'
12
12
 
13
13
  # Merge multiple CSS RuleSets by cascading according to the CSS 2.1 cascading rules
14
14
  # (http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order).
@@ -78,16 +78,14 @@ module CssParser
78
78
  # Add the property to the list to be folded per http://www.w3.org/TR/CSS21/cascade.html#cascading-order
79
79
  if not properties.has_key?(property)
80
80
  properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
81
+ elsif is_important and not properties[property][:is_important]
82
+ properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
81
83
  elsif properties[property][:specificity] < specificity or properties[property][:specificity] == specificity
82
84
  unless properties[property][:is_important]
83
85
  properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
84
86
  end
85
87
  end
86
-
87
- if is_important
88
- properties[property] = {:value => value, :specificity => specificity, :is_important => is_important}
89
- end
90
- end
88
+ end
91
89
  end
92
90
 
93
91
  merged = RuleSet.new(nil, nil)
data/test/test_merging.rb CHANGED
@@ -93,6 +93,13 @@ class MergingTests < Test::Unit::TestCase
93
93
  assert_equal 'black !important;', merged['color']
94
94
  end
95
95
 
96
+ def test_merging_multiple_important
97
+ rs1 = RuleSet.new(nil, 'color: black !important;', 1000)
98
+ rs2 = RuleSet.new(nil, 'color: red !important;', 1)
99
+ merged = CssParser.merge(rs1, rs2)
100
+ assert_equal 'black !important;', merged['color']
101
+ end
102
+
96
103
  def test_merging_shorthand_important
97
104
  rs1 = RuleSet.new(nil, 'background: black none !important;')
98
105
  rs2 = RuleSet.new(nil, 'background-color: red;')
@@ -59,6 +59,15 @@ class RuleSetCreatingShorthandTests < Test::Unit::TestCase
59
59
  assert_equal '', combined['margin']
60
60
  assert_equal '', combined['padding']
61
61
  end
62
+
63
+ # ==== Dimensions shorthand, auto property
64
+ def test_combining_dimensions_into_shorthand_with_auto
65
+ rs = RuleSet.new('#page', "margin: 0; margin-left: auto; margin-right: auto;")
66
+ rs.expand_shorthand!
67
+ assert_equal('auto;', rs['margin-left'])
68
+ rs.create_shorthand!
69
+ assert_equal('0 auto;', rs['margin'])
70
+ end
62
71
 
63
72
  # ==== Font shorthand
64
73
  def test_combining_font_into_shorthand
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
16
- requirement: &2154706420 !ruby/object:Gem::Requirement
16
+ requirement: &2155990880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2154706420
24
+ version_requirements: *2155990880
25
25
  description: A set of classes for parsing CSS in Ruby.
26
26
  email: code@dunae.ca
27
27
  executables: []