mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 08:31:51 +00:00
LibWeb/CSS: Allow empty trailing group when parsing comma-separated list
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
There's discussion in the linked spec issue, but the short version is, this algorithm will see "foo,bar," as a list of two groups, with "foo" in the first group and "bar" in the second. However, users of this want to get a list of three groups, with the last one being empty. So, do that!
This commit is contained in:
parent
338282f74d
commit
233022c473
Notes:
github-actions[bot]
2025-05-17 06:54:29 +00:00
Author: https://github.com/AtkinsSJ
Commit: 233022c473
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4783
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 13 additions and 8 deletions
|
@ -1309,15 +1309,21 @@ Vector<Vector<ComponentValue>> Parser::parse_a_comma_separated_list_of_component
|
|||
Vector<Vector<ComponentValue>> groups;
|
||||
|
||||
// 3. While input is not empty:
|
||||
bool just_consumed_comma = false;
|
||||
while (!input.is_empty()) {
|
||||
|
||||
// 1. Consume a list of component values from input, with <comma-token> as the stop token, and append the result to groups.
|
||||
groups.append(consume_a_list_of_component_values(input, Token::Type::Comma));
|
||||
|
||||
// 2. Discard a token from input.
|
||||
input.discard_a_token();
|
||||
just_consumed_comma = input.consume_a_token().is(Token::Type::Comma);
|
||||
}
|
||||
|
||||
// AD-HOC: Also append an empty group if there was a trailing comma.
|
||||
// Some related spec discussion: https://github.com/w3c/csswg-drafts/issues/11254
|
||||
if (just_consumed_comma)
|
||||
groups.append({});
|
||||
|
||||
// 4. Return groups.
|
||||
return groups;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue