Parse ruleset with `not(.asd, .ass)`
stoivo opened this issue · 11 comments
I have a css rule with :not(.asd, .ass)
and it becomes separated into two different rule_sets. I worked around it in my project by removing the space, :not(.asd, .ass)
=> :not(.asd,.ass)
.
I have traced the issue to lib/css_parser/parser.rb#L329.
css_parser/lib/css_parser/parser.rb
Line 329 in 2b0e89c
Also included a script to reproduce.
require 'css_parser'
parser = CssParser::Parser.new
parser.load_string! "a:not(.asd, .ass) { color: hotpink; }"
parser.each_rule_set do |rule_set, media_types|
puts "rule_set #{rule_set}"
rule_set.selectors.each do |selector_string|
puts " selector_string #{selector_string}"
end
end
# output:
# rule_set a:not(.asd,.ass) { color: hotpink; }
# selector_string a:not(.asd
# selector_string .ass)
PR welcome as long as it does not break other tests :)
ok, I will see if I can come up with something. I'm a bit afraid to change it since it's soo core to the code
Can I be confident that if the spec passes everything is good?
I have been looking a bit around. I would like to rewrite the parser. Are you open for a merge request which replaces
css_parser/lib/css_parser/parser.rb
Lines 307 to 424 in 2b0e89c
if you can somehow keep or lower the complexity and runtime then I'm in favor
(+tests mostly need to keep passing)
I'd not be a fan of tons of added complexity or significant runtime increase
Ok, thanks. I will see what I can do. I will add new spec too.