Media query should reset to :all
Closed this issue · 2 comments
twe4ked commented
After a @media
block, the next RuleSet
’s :media_types
is empty when it should be [:all]
.
$: << 'lib'
require 'css_parser'
css = <<CSS
body { background: red; }
@media screen {
body { background: green; }
}
body { background: blue; }'
CSS
parser = CssParser::Parser.new
parser.load_string! css
p parser.instance_variable_get('@rules').map { |r| r[:media_types] }
# Expected: [[:all], [:screen], [:all]]
# Actual: [[:all], [:screen], []]
p parser.rules_by_media_query
# Expected: {:all=>[body { background: red; }, body { background: blue; }], :screen=>[body { background: green; }]}
# Actual: {:all=>[body { background: red; }], :screen=>[body { background: green; }]}
ben-eb commented
I've ran into this issue when parsing Twitter's Bootstrap; css_parser prints out the :all declaration, then the :print, then stops and ignores the rest of the css after that. Is this an easy thing to fix?