Skip to content

Commit

Permalink
Implement step_in_select_in_table
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Jul 17, 2024
1 parent 14c3169 commit 8fc04f7
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,7 @@ private function step_in_select() {
* 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.
*
Expand All @@ -2494,7 +2494,52 @@ private function step_in_select() {
* @return bool Whether an element was found.
*/
private function step_in_select_in_table() {
$this->bail( "No support for parsing in the '{$this->state->insertion_mode}' 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();
}

/**
Expand Down

0 comments on commit 8fc04f7

Please sign in to comment.