LibWeb/CSS: Require that tag-name simple selectors go first

This fixes 1 subtest.
This commit is contained in:
Sam Atkins 2024-11-08 20:14:46 +00:00 committed by Andreas Kling
parent a0403ac427
commit 219346011b
Notes: github-actions[bot] 2024-11-09 13:30:31 +00:00
2 changed files with 6 additions and 3 deletions

View file

@ -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; }}
@ -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; }}

View file

@ -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());
}