Skip to content

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Jul 22, 2025

Trac ticket: #63736

The HTML standard is being updated to support customizable select elements. The HTML API should be updated to account for the new changes.

WHATWG/HTML PR 10548 had landed with the updates. Several browsers already have support and MDN pages have been updated for select, selectedcontent, and a new guide on customizable select elements.

There's also an html5-lib tests PR that updates tests to account for the changes.

Update HTML API parsing to account for changes in whatwg/html#10548.

Apply html5lib/html5lib-tests#178.

Todo:

  • Update the html5lib-tests README and sha when the PR lands.

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@sirreal sirreal self-assigned this Jul 22, 2025
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

When SELECT > BUTTON > SELECTEDCONTENT is encountered, the selected
option may need to be cloned into the SELECTEDCONTENT. The HTML
processor does not support this action as it may require out of order
processing.
@sirreal sirreal marked this pull request as ready for review July 22, 2025 12:44
@sirreal sirreal requested a review from dmsnell July 22, 2025 12:44
Copy link

github-actions bot commented Jul 22, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell, dmsnell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal
Copy link
Member Author

sirreal commented Jul 22, 2025

@sirreal
Copy link
Member Author

sirreal commented Sep 10, 2025

The html5lib-tests updates were merged: html5lib/html5lib-tests#178

Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s taken me some time but I reviewed the changes to the HTML Spec and compared against this and I appreciate the thoroughness with which you implemented them.

  • I wanted before to add a reference to the spec version. This would be good to add here, so someone can cross-reference historically when the changes appeared. This can go in the module or class docblock I think.
  • We can put this into 6.9, so {WP_VERSION} can be updated.
  • Let’s review and harmonize all of the deprecations, both in coordinating the docblock annotations with the call to _deprecated_function() and in emptying things like the select scope code.

Not yet have I reviewed this against the SELECTEDCONTENT changes, but I think we will be able to largely ignore the semantics, since that appears at render time by the browser. It may be worth adding a note in the class docs indicating the level of support.

*
* @param string $tag_name Name of tag to check.
* @return bool Whether the given element is in SELECT scope.
*/
public function has_element_in_select_scope( string $tag_name ): bool {
_deprecated_function( __METHOD__, '{WP_VERSION}' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don’t know how the docblock tag and the function call interact. Do you feel like you have a strong understand? Are both expected/appropriate?

*
* @param string $tag_name Name of tag to check.
* @return bool Whether the given element is in SELECT scope.
*/
public function has_element_in_select_scope( string $tag_name ): bool {
_deprecated_function( __METHOD__, '{WP_VERSION}' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also be able to remove the body from this function and always return false since the actual select scope no longer exists

* > 1. Parse error.
* > 2. Ignore the token.
*/
if ( null !== $this->context_node && 'SELECT' === $this->context_node->node_name ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we appear to be inconsistent here, but I think I have tried to use isset( $this->context_node ) over null checks.

* > An end tag whose tag name is "option"
*
* The "option" end tag is handled in the any other end tag section below.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this comment here? I am guessing it was added because it used to be in the code as a specific case but now it isn’t? If so, I don’t see a reason to duplicate the description that it’s handled by the catch-all.

@dmsnell
Copy link
Member

dmsnell commented Sep 10, 2025

Screenshot 2025-09-10 at 12 18 46 PM

My reading on this is that when we close an OPTION element we check if we are the first element with selected and that the parent SELECT is not a multiple.

If that’s the case we should be able to infer that we are inside a SELECTEDCONTENT and fib it, should we want to. This is something we could possibly track through a boolean flag in the parser.

Interesting the spec reads like this cloning only occurs when encountering an end tag whose name is OPTION. That’s not what Chrome is doing, because it clones the element when there are no closing tags. It’s like they are doing it upon the event of closing the OPTION instead of encountering the end tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants