Block Style Variations: Simplify block style variation selector regex - #12429
aaronrobertshaw wants to merge 1 commit into
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
andrewserong
left a comment
There was a problem hiding this comment.
This matches the GB PR and is already covered by tests, so this LGTM and I don't think it needs a ticket annotation since it's effectively a no-op. Good idea adding the extra comment to clarify the expected matches.
LGTM
ramonjd
left a comment
There was a problem hiding this comment.
Matches WordPress/gutenberg#79924, which I tested. Test pass.
|
I would appreciate it if you could commit this PR in time for the 7.1 Beta1 release on July 15. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
2874f59 to
d317f6d
Compare
I'll get it in 👍🏻 Thanks @t-hamano |
What?
Backports Gutenberg PR WordPress/gutenberg#79924 to Core, tidying up the regex used to add a block style variation's class (e.g.
.is-style-custom) to a block's selector inWP_Theme_JSON.Trac ticket: https://core.trac.wordpress.org/ticket/65588
Why?
The regex is hard to follow and its first capture group is effectively dead. It only matches a literal
:(...), which isn't valid selector syntax (functional pseudo-classes like:is()and:where()always have a name between the colon and the parenthesis), so$matches[1]is always empty. The second group does all the work, so dropping the dead group gives identical output and is much easier to follow.How?
/((?::\([^)]+\))?\s*)([^\s:]+)/to/[^\s:]+/and adds a comment with worked examples.$/\being interpreted).The
:isselector-list test case from the Gutenberg change already exists in Core's suite (tests/phpunit/tests/theme/wpThemeJson.php), so no test change was needed here.Testing Instructions
This is a behaviour-preserving change, so the output should be identical to
trunk.test_get_block_style_variation_selectorPHP tests pass