LibWeb/CSS: Discard whitespace when parsing comma-separated lists

This commit is contained in:
Sam Atkins 2025-10-28 15:23:08 +00:00
parent 9dc9e98d14
commit 821bf4a289
Notes: github-actions[bot] 2025-11-03 11:29:43 +00:00
3 changed files with 14 additions and 8 deletions

View file

@ -186,6 +186,7 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
return {};
};
tokens.discard_whitespace();
auto& peek_token = tokens.next_token();
auto parse_for_type = [&](ValueType const type) -> Optional<PropertyAndValue> {

View file

@ -80,7 +80,9 @@ namespace Web::CSS::Parser {
RefPtr<StyleValue const> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
{
tokens.discard_whitespace();
auto first = parse_one_value(tokens);
tokens.discard_whitespace();
if (!first || !tokens.has_next_token())
return first;
@ -91,8 +93,11 @@ RefPtr<StyleValue const> Parser::parse_comma_separated_value_list(TokenStream<Co
if (!tokens.consume_a_token().is(Token::Type::Comma))
return nullptr;
tokens.discard_whitespace();
if (auto maybe_value = parse_one_value(tokens)) {
values.append(maybe_value.release_nonnull());
tokens.discard_whitespace();
continue;
}
return nullptr;