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 https://github.com/wordpress/wordpress-develop/pull/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: http://core.svn.wordpress.org/trunk@58237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dmsnell 2024-08-01 22:53:16 +00:00
parent 40114e8ed5
commit 90a66c7ad1
2 changed files with 48 additions and 3 deletions

View File

@ -3771,7 +3771,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* This internal function performs the 'in select in table' insertion mode
* logic for the generalized WP_HTML_Processor::step() function.
*
* @since 6.7.0 Stub implementation.
* @since 6.7.0
*
* @throws WP_HTML_Unsupported_Exception When encountering unsupported HTML input.
*
@ -3781,7 +3781,52 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* @return bool Whether an element was found.
*/
private function step_in_select_in_table(): bool {
$this->bail( 'No support for parsing in the ' . WP_HTML_Processor_State::INSERTION_MODE_IN_SELECT_IN_TABLE . ' state.' );
$token_name = $this->get_token_name();
$token_type = $this->get_token_type();
$op_sigil = '#tag' === $token_type ? ( parent::is_tag_closer() ? '-' : '+' ) : '';
$op = "{$op_sigil}{$token_name}";
switch ( $op ) {
/*
* > A start tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"
*/
case '+CAPTION':
case '+TABLE':
case '+TBODY':
case '+TFOOT':
case '+THEAD':
case '+TR':
case '+TD':
case '+TH':
// @todo Indicate a parse error once it's possible.
$this->state->stack_of_open_elements->pop_until( 'SELECT' );
$this->reset_insertion_mode();
return $this->step( self::REPROCESS_CURRENT_NODE );
/*
* > An end tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"
*/
case '-CAPTION':
case '-TABLE':
case '-TBODY':
case '-TFOOT':
case '-THEAD':
case '-TR':
case '-TD':
case '-TH':
// @todo Indicate a parse error once it's possible.
if ( ! $this->state->stack_of_open_elements->has_element_in_table_scope( $token_name ) ) {
return $this->step();
}
$this->state->stack_of_open_elements->pop_until( 'SELECT' );
$this->reset_insertion_mode();
return $this->step( self::REPROCESS_CURRENT_NODE );
}
/*
* > Anything else
*/
return $this->step_in_select();
}
/**

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58840';
$wp_version = '6.7-alpha-58841';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.