Skip to content

Commit 234ae9b

Browse files
committed
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 WordPress#9298. Props jonsurrell, dmsnell. Fixes #63736. git-svn-id: https://develop.svn.wordpress.org/trunk@62689 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3ec2726 commit 234ae9b

6 files changed

Lines changed: 174 additions & 381 deletions

File tree

src/wp-includes/html-api/class-wp-html-open-elements.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ public function has_element_in_specific_scope( string $tag_name, $termination_li
281281
* > - th
282282
* > - marquee
283283
* > - object
284+
* > - select
284285
* > - template
285286
* > - MathML mi
286287
* > - MathML mo
@@ -312,6 +313,7 @@ public function has_element_in_scope( string $tag_name ): bool {
312313
'TH',
313314
'MARQUEE',
314315
'OBJECT',
316+
'SELECT',
315317
'TEMPLATE',
316318

317319
'math MI',
@@ -362,6 +364,7 @@ public function has_element_in_list_item_scope( string $tag_name ): bool {
362364
'MARQUEE',
363365
'OBJECT',
364366
'OL',
367+
'SELECT',
365368
'TEMPLATE',
366369
'UL',
367370

@@ -410,6 +413,7 @@ public function has_element_in_button_scope( string $tag_name ): bool {
410413
'TH',
411414
'MARQUEE',
412415
'OBJECT',
416+
'SELECT',
413417
'TEMPLATE',
414418

415419
'math MI',
@@ -459,9 +463,8 @@ public function has_element_in_table_scope( string $tag_name ): bool {
459463
/**
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
467470
* > that element in the specific scope consisting of all element types except the following:
@@ -471,24 +474,14 @@ public function has_element_in_table_scope( string $tag_name ): bool {
471474
* @since 6.4.0 Stub implementation (throws).
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;
494487
}
@@ -697,6 +690,7 @@ public function after_element_push( WP_HTML_Token $item ): void {
697690
case 'TH':
698691
case 'MARQUEE':
699692
case 'OBJECT':
693+
case 'SELECT':
700694
case 'TEMPLATE':
701695
case 'math MI':
702696
case 'math MO':
@@ -753,6 +747,7 @@ public function after_element_pop( WP_HTML_Token $item ): void {
753747
case 'TH':
754748
case 'MARQUEE':
755749
case 'OBJECT':
750+
case 'SELECT':
756751
case 'TEMPLATE':
757752
case 'math MI':
758753
case 'math MO':

src/wp-includes/html-api/class-wp-html-processor-state.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ class WP_HTML_Processor_State {
209209
*
210210
* @since 6.7.0
211211
*
212-
* @see https://html.spec.whatwg.org/#parsing-main-inselect
212+
* @deprecated 7.1.0 The "in select" insertion mode was removed from the standard.
213+
* @ignore
214+
*
213215
* @see WP_HTML_Processor_State::$insertion_mode
214216
*
215217
* @var string
@@ -221,7 +223,9 @@ class WP_HTML_Processor_State {
221223
*
222224
* @since 6.7.0
223225
*
224-
* @see https://html.spec.whatwg.org/#parsing-main-inselectintable
226+
* @deprecated 7.1.0 The "in select in table" insertion mode was removed from the standard.
227+
* @ignore
228+
*
225229
* @see WP_HTML_Processor_State::$insertion_mode
226230
*
227231
* @var string

0 commit comments

Comments
 (0)