css_parser icon indicating copy to clipboard operation
css_parser copied to clipboard

keyframes parsing as empty declarations

Open rockrep opened this issue 8 years ago • 4 comments

css with @keyframes rules parse as empty rule sets

css_parser (1.4.1)

css = "@keyframes shimmer {\n  0% {\n    background-position: top left;\n  }\n  100% {\n    background-position: top right;\n  }\n}"
parser = CssParser::Parser.new
parser.add_block!(css)
parser.each_rule_set do |rule_set, media_types|
  p rule_set
end

#<CssParser::RuleSet:0x007fca9ce49030 @selectors=["@keyframes shimmer"], @specificity=nil, @declarations={}, @order=0>
=> [{:media_types=>[:all], :rules=>#<CssParser::RuleSet:0x007fca9ce49030 @declarations={}, @order=0, @selectors=["@keyframes shimmer"], @specificity=nil>}]

rockrep avatar Mar 24 '16 23:03 rockrep

Please open a PR :)

grosser avatar Mar 24 '16 23:03 grosser

Would be happy to. But I could use a clue as to where the fix should go

rockrep avatar Mar 28 '16 15:03 rockrep

sry, no idea, I'm not really an expert on the internals ... maybe check a few recent PRs ... chances are it's a similar area ...

grosser avatar Mar 28 '16 16:03 grosser

@keyframes uses nested braces of declarations, and the rest of the parser code in https://github.com/premailer/css_parser/blob/master/lib/css_parser/parser.rb#L248 isn't really setup to handle that. A fix has eluded me so far.

rockrep avatar Mar 29 '16 17:03 rockrep