Repository navigation
Conversation
Selector lists in theme.json, block supports, duotone and the style engine are split with explode( ',' ) or with scanners that track some nesting, which split inside strings, escapes, comments or blocks. Their callers need the source text of each selector, as written, to prepend or append to it. The method returns the source text between top-level commas, found by tokenizing the input. Joining the items with commas reproduces the input. A comma at the end of the input produces a final empty item, as the selector grammar rejects a trailing comma and the CSS Syntax 3 algorithm does not show one.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
…omma-separated-list-text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caution
This is a work in progress draft and is not ready for any serious review.
Add
WP_CSS_Token_Processor::split_comma_separated_list( $css ), which returns the source text between top-level commas. A comma inside a string, comment, escape, url token, function,(),[]or{}block stays in its item. Joining the items with commas reproduces the input.Selector lists are comma-separated, and their callers in core prepend or append text to each selector as written, so they need text rather than tokens. Core splits them with
explode( ',' )or with scanners that track some of the cases above:explode( ',' )split_comma_separated_list()[title="a,b"], c[title="a,b"],c[title="a,b"],c:is(a, b) img, c:is(a,b) img,c:is(a, b) img,cThe method tokenizes the whole input. It follows the CSS Syntax 3 algorithm with one difference: a comma at the end of the input produces a final empty item, because the selector grammar rejects a trailing comma and the algorithm's result does not show one.
#98 adds the token form of the same split,
parse_comma_separated_list(). The selector-list alternative, #102, uses this method.Depends on WordPress#14781.
Trac ticket: TBD
Use of AI Tools
AI assistance: Yes
Tools: Claude Code
Models: Claude Opus 5.5
Used for: implementation, tests and this description.
This pull request is for code review only. Keep other discussion in the Trac ticket. Do not merge. See GitHub Pull Requests for Code Review in the Core Handbook.