-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Bindings: Simplify the HTML replacement logic until the HTML API is ready #61236
Block Bindings: Simplify the HTML replacement logic until the HTML API is ready #61236
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in a2d9f08. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8894082376
|
lib/compat/wordpress-6.5/blocks.php
Outdated
$block_reader->release_bookmark( 'iterate-selectors' ); | ||
return $block_content; | ||
if ( 'core/button' === $block_name && 'text' === $attribute_name ) { | ||
$selector = 'a'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a button block can also be a <button>
element depending on the value of the tagName
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right it seems supported according to the attributes. Although I checked how that attribute works and I couldn't find a way to use a <button>
instead of a link tag.
I added this commit to cover that possibility.
57c2ce1
to
3473e82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected.
Should we update it in |
Yes, I plan to create a backport PR, but I wanted to wait to confirm this was the right approach. I'll do that. |
What?
Change the block bindings HTML replacement logic to use a hardcoded list of selectors based on the block and a regex to substitute the inner content.
Why?
The existing logic is too complex because the HTML API doesn't support CSS selectors yet and it doesn't have an official way to modify the inner HTML. This makes it difficult to understand, iterate on it and add new functionalities.
As it will be solved in the future once the HTML API is ready, I believe it is better to keep a simple hardcoded version that is easier to understand and iterate on.
How?
Testing Instructions