Skip to content

Commit

Permalink
Improve how whitespace is consumed in complex selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Jun 5, 2024
1 parent 57a45cb commit c2b5853
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/syntax_tree/css/selectors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,14 @@ def complex_selector
child_nodes = [compound_selector]

loop do
maybe { consume_whitespace }

if (c = maybe { combinator })
child_nodes << c

maybe { consume_whitespace }
end

if (s = maybe { compound_selector })
child_nodes << s
else
Expand All @@ -363,8 +368,6 @@ def relative_selector
# <compound-selector> = [ <type-selector>? <subclass-selector>*
# [ <pseudo-element-selector> <pseudo-class-selector>* ]* ]!
def compound_selector
consume_whitespace

type = maybe { type_selector }
subclasses = []

Expand Down Expand Up @@ -401,8 +404,6 @@ def simple_selector

# <combinator> = '>' | '+' | '~' | [ '|' '|' ]
def combinator
consume_whitespace

value =
options do
maybe { consume(">") } ||
Expand Down

0 comments on commit c2b5853

Please sign in to comment.