1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

LibWeb: Restore :is() and :where() selector parsing

This was a casualty in a recent merge-conflict resolution. Oops!
This commit is contained in:
Sam Atkins 2022-03-23 17:45:30 +00:00 committed by Tim Flynn
parent 0e51d99322
commit 004f69b535

View file

@ -560,7 +560,22 @@ Result<Selector::SimpleSelector, Parser::ParsingResult> Parser::parse_pseudo_sim
};
auto const& pseudo_function = pseudo_class_token.function();
if (pseudo_function.name().equals_ignoring_case("not")) {
if (pseudo_function.name().equals_ignoring_case("is"sv)
|| pseudo_function.name().equals_ignoring_case("where"sv)) {
auto function_token_stream = TokenStream(pseudo_function.values());
auto argument_selector_list = parse_a_selector_list(function_token_stream, SelectorType::Standalone, SelectorParsingMode::Forgiving);
// NOTE: Because it's forgiving, even complete garbage will parse OK as an empty selector-list.
VERIFY(!argument_selector_list.is_error());
return Selector::SimpleSelector {
.type = Selector::SimpleSelector::Type::PseudoClass,
.value = Selector::SimpleSelector::PseudoClass {
.type = pseudo_function.name().equals_ignoring_case("is"sv)
? Selector::SimpleSelector::PseudoClass::Type::Is
: Selector::SimpleSelector::PseudoClass::Type::Where,
.argument_selector_list = argument_selector_list.release_value() }
};
} else if (pseudo_function.name().equals_ignoring_case("not")) {
auto function_token_stream = TokenStream(pseudo_function.values());
auto not_selector = parse_a_selector_list(function_token_stream, SelectorType::Standalone);
if (not_selector.is_error()) {