LibWeb: Throw parsing error if ::slotted() argument is not 1 compound

...selector. Grammar per spec: `::slotted( <compound-selector> )`, so
we should reject selector as invalid if first compound selector is
followed by something else.

This change makes layout more correct on https://www.rottentomatoes.com/
This commit is contained in:
Aliaksandr Kalenik 2025-09-04 13:16:23 +02:00 committed by Sam Atkins
commit 308c2eab0e
Notes: github-actions[bot] 2025-09-04 12:56:37 +00:00
3 changed files with 54 additions and 0 deletions

View file

@ -517,6 +517,15 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
});
return ParseError::SyntaxError;
}
function_tokens.discard_whitespace();
if (function_tokens.has_next_token()) {
ErrorReporter::the().report(InvalidPseudoClassOrElementError {
.name = MUST(String::formatted("::{}", pseudo_name)),
.value_string = name_token.to_string(),
.description = "Trailing tokens after compound selector argument."_string,
});
return ParseError::SyntaxError;
}
auto compound_selector = compound_selector_or_error.release_value().release_value();
compound_selector.combinator = Selector::Combinator::None;