premailer / css_parser

Ruby CSS Parser
Other
279 stars 110 forks source link

`expand_shorthand!` overrides subsequent styles #111

Closed ojab closed 3 years ago

ojab commented 3 years ago

If line-height, for example, is set after font — it gets overridden:

> rule_set = CssParser::RuleSet.new(nil, 'font:15px; line-height:0')
=> #<CssParser::RuleSet:0x00000000040a11e0 @declarations={"font"=>{:value=>"15px", :is_important=>false, :order=>1}, "line-height"=>{:value=>"0", :is_important=>false, :order=>2}}, @order=2, @selectors=[], @specificity=nil>
> rule_set.expand_shorthand!
=> nil
> rule_set
=> #<CssParser::RuleSet:0x00000000040a11e0
 @declarations=
  {"line-height"=>{:value=>"normal", :is_important=>false, :order=>1},
   "font-style"=>{:value=>"normal", :is_important=>false, :order=>1},
   "font-variant"=>{:value=>"normal", :is_important=>false, :order=>1},
   "font-weight"=>{:value=>"normal", :is_important=>false, :order=>1},
   "font-size"=>{:value=>"15px", :is_important=>false, :order=>1}},
 @order=2,
 @selectors=[],
 @specificity=nil>