Skip to content

Commit 3bd9754

Browse files
committed
HTML API: Add support for IN SELECT IN TABLE parsing.
As part of work to add more spec support to the HTML API, this patch adds support for the IN SELECT IN TABLE insertion mode. This small section of the spec handles rules for the `<select>` element and its children when found inside of a `<table>`. Developed in WordPress/wordpress-develop#7044 Discussed in https://core.trac.wordpress.org/ticket/61576 Props: dmsnell, jonsurrell. See #61576. Built from https://develop.svn.wordpress.org/trunk@58841 git-svn-id: https://core.svn.wordpress.org/trunk@58237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 810fa58 commit 3bd9754

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

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

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3771,7 +3771,7 @@ private function step_in_select(): bool {
37713771
* This internal function performs the 'in select in table' insertion mode
37723772
* logic for the generalized WP_HTML_Processor::step() function.
37733773
*
3774-
* @since 6.7.0 Stub implementation.
3774+
* @since 6.7.0
37753775
*
37763776
* @throws WP_HTML_Unsupported_Exception When encountering unsupported HTML input.
37773777
*
@@ -3781,7 +3781,52 @@ private function step_in_select(): bool {
37813781
* @return bool Whether an element was found.
37823782
*/
37833783
private function step_in_select_in_table(): bool {
3784-
$this->bail( 'No support for parsing in the ' . WP_HTML_Processor_State::INSERTION_MODE_IN_SELECT_IN_TABLE . ' state.' );
3784+
$token_name = $this->get_token_name();
3785+
$token_type = $this->get_token_type();
3786+
$op_sigil = '#tag' === $token_type ? ( parent::is_tag_closer() ? '-' : '+' ) : '';
3787+
$op = "{$op_sigil}{$token_name}";
3788+
3789+
switch ( $op ) {
3790+
/*
3791+
* > A start tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"
3792+
*/
3793+
case '+CAPTION':
3794+
case '+TABLE':
3795+
case '+TBODY':
3796+
case '+TFOOT':
3797+
case '+THEAD':
3798+
case '+TR':
3799+
case '+TD':
3800+
case '+TH':
3801+
// @todo Indicate a parse error once it's possible.
3802+
$this->state->stack_of_open_elements->pop_until( 'SELECT' );
3803+
$this->reset_insertion_mode();
3804+
return $this->step( self::REPROCESS_CURRENT_NODE );
3805+
3806+
/*
3807+
* > An end tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"
3808+
*/
3809+
case '-CAPTION':
3810+
case '-TABLE':
3811+
case '-TBODY':
3812+
case '-TFOOT':
3813+
case '-THEAD':
3814+
case '-TR':
3815+
case '-TD':
3816+
case '-TH':
3817+
// @todo Indicate a parse error once it's possible.
3818+
if ( ! $this->state->stack_of_open_elements->has_element_in_table_scope( $token_name ) ) {
3819+
return $this->step();
3820+
}
3821+
$this->state->stack_of_open_elements->pop_until( 'SELECT' );
3822+
$this->reset_insertion_mode();
3823+
return $this->step( self::REPROCESS_CURRENT_NODE );
3824+
}
3825+
3826+
/*
3827+
* > Anything else
3828+
*/
3829+
return $this->step_in_select();
37853830
}
37863831

37873832
/**

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.7-alpha-58840';
19+
$wp_version = '6.7-alpha-58841';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)