Skip to content

Commit

Permalink
LibWeb/CSS: Require that tag-name simple selectors go first
Browse files Browse the repository at this point in the history
This fixes 1 subtest.
  • Loading branch information
AtkinsSJ committed Nov 8, 2024
1 parent fa49a2c commit daaa197
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Rerun

Found 32 tests

31 Pass
1 Fail
32 Pass
Details
Result Test Name MessagePass .foo { & { color: green; }}
Pass .foo { &.bar { color: green; }}
Expand All @@ -26,7 +25,7 @@ Pass .foo { &:is(.bar, .baz) { color: green; }}
Pass .foo { :is(.bar, &.baz) { color: green; }}
Pass .foo { &:is(.bar, &.baz) { color: green; }}
Pass .foo { div& { color: green; }}
Fail INVALID: .foo { &div { color: green; }}
Pass INVALID: .foo { &div { color: green; }}
Pass .foo { .class& { color: green; }}
Pass .foo { &.class { color: green; }}
Pass .foo { [attr]& { color: green; }}
Expand Down
4 changes: 4 additions & 0 deletions Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Parser::ParseErrorOr<Optional<Selector::CompoundSelector>> Parser::parse_compoun
auto component = TRY(parse_simple_selector(tokens));
if (!component.has_value())
break;
if (component->type == Selector::SimpleSelector::Type::TagName && !simple_selectors.is_empty()) {
// Tag-name selectors can only go at the beginning of a compound selector.
return ParseError::SyntaxError;
}
simple_selectors.append(component.release_value());
}

Expand Down

0 comments on commit daaa197

Please sign in to comment.