From 640a980080f8667c458fd39cf239a2ed89fe2d16 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sun, 12 Sep 2021 16:15:19 +0100 Subject: [PATCH] LibWeb: Parse CSS selectors with no space before a combinator Previously selectors like `.foo>.bar` did not parse, because there is no whitespace between `.foo` and `>`. Now we correctly parse these. :^) --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 0b27b92cc0..2f907ac40d 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -637,6 +637,16 @@ Result Parser::parse_si } } + // Whitespace is not required between the compound-selector and a combinator. + // So, if we see a combinator, return that this compound-selector is done, instead of a syntax error. + if (first_value.is(Token::Type::Delim)) { + auto delim = first_value.token().delim(); + if ((delim == ">"sv) || (delim == "+"sv) || (delim == "~"sv) || (delim == "|"sv)) { + tokens.reconsume_current_input_token(); + return SelectorParsingResult::Done; + } + } + dbgln_if(CSS_PARSER_DEBUG, "!!! Invalid simple selector!"); return SelectorParsingResult::SyntaxError; }