Make WordPress Core


Ignore:
Timestamp:
07/10/2026 05:22:53 PM (2 months ago)
Author:
jonsurrell
Message:

HTML API: Update SELECT element parsing according to specification.

The HTML standard was updated to support customizable SELECT elements. Update HTML API parsing accordingly.

Developed in https://github.com/WordPress/wordpress-develop/pull/9298.

Props jonsurrell, dmsnell.
Fixes #63736.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-open-elements.php

    r62575 r62689  
    282282         * >   - marquee
    283283         * >   - object
     284         * >   - select
    284285         * >   - template
    285286         * >   - MathML mi
     
    313314                                'MARQUEE',
    314315                                'OBJECT',
     316                                'SELECT',
    315317                                'TEMPLATE',
    316318
     
    363365                                'OBJECT',
    364366                                'OL',
     367                                'SELECT',
    365368                                'TEMPLATE',
    366369                                'UL',
     
    411414                                'MARQUEE',
    412415                                'OBJECT',
     416                                'SELECT',
    413417                                'TEMPLATE',
    414418
     
    460464         * Returns whether a particular element is in select scope.
    461465         *
    462          * This test differs from the others like it, in that its rules are inverted.
    463          * Instead of arriving at a match when one of any tag in a termination group
    464          * is reached, this one terminates if any other tag is reached.
     466         * The "select scope" concept was removed from the HTML standard along with the
     467         * customizable `<select>` changes, so nothing is ever in select scope.
    465468         *
    466469         * > The stack of open elements is said to have a particular element in select scope when it has
     
    472475         * @since 6.7.0 Full implementation.
    473476         *
    474          * @see https://html.spec.whatwg.org/#has-an-element-in-select-scope
     477         * @deprecated 7.1.0 This method is no longer part of the HTML standard.
     478         * @ignore
    475479         *
    476480         * @param string $tag_name Name of tag to check.
    477          * @return bool Whether the given element is in SELECT scope.
     481         * @return bool Always false; select scope no longer exists.
    478482         */
    479483        public function has_element_in_select_scope( string $tag_name ): bool {
    480                 foreach ( $this->walk_up() as $node ) {
    481                         if ( $node->node_name === $tag_name ) {
    482                                 return true;
    483                         }
    484 
    485                         if (
    486                                 'OPTION' !== $node->node_name &&
    487                                 'OPTGROUP' !== $node->node_name
    488                         ) {
    489                                 return false;
    490                         }
    491                 }
     484                _deprecated_function( __METHOD__, '7.1.0' );
    492485
    493486                return false;
     
    698691                        case 'MARQUEE':
    699692                        case 'OBJECT':
     693                        case 'SELECT':
    700694                        case 'TEMPLATE':
    701695                        case 'math MI':
     
    754748                        case 'MARQUEE':
    755749                        case 'OBJECT':
     750                        case 'SELECT':
    756751                        case 'TEMPLATE':
    757752                        case 'math MI':
Note: See TracChangeset for help on using the changeset viewer.