WP_HTML_Processor::step_in_cell
Parses next element in the 'in cell' insertion mode.
This internal function performs the 'in cell' insertion mode logic for the generalized WP_HTML_Processor::step() function.
Method of the class: WP_HTML_Processor{}
No Hooks.
Returns
true|false. Whether an element was found.
Usage
// private - for code of main (parent) class only $result = $this->step_in_cell(): bool;
Notes
Changelog
| Since 6.7.0 | Introduced. |
WP_HTML_Processor::step_in_cell() WP HTML Processor::step in cell code WP 6.8.3
private function step_in_cell(): bool {
$tag_name = $this->get_tag();
$op_sigil = $this->is_tag_closer() ? '-' : '+';
$op = "{$op_sigil}{$tag_name}";
switch ( $op ) {
/*
* > An end tag whose tag name is one of: "td", "th"
*/
case '-TD':
case '-TH':
if ( ! $this->state->stack_of_open_elements->has_element_in_table_scope( $tag_name ) ) {
// Parse error: ignore the token.
return $this->step();
}
$this->generate_implied_end_tags();
/*
* @todo This needs to check if the current node is an HTML element, meaning that
* when SVG and MathML support is added, this needs to differentiate between an
* HTML element of the given name, such as `<center>`, and a foreign element of
* the same given name.
*/
if ( ! $this->state->stack_of_open_elements->current_node_is( $tag_name ) ) {
// @todo Indicate a parse error once it's possible.
}
$this->state->stack_of_open_elements->pop_until( $tag_name );
$this->state->active_formatting_elements->clear_up_to_last_marker();
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_ROW;
return true;
/*
* > A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td",
* > "tfoot", "th", "thead", "tr"
*/
case '+CAPTION':
case '+COL':
case '+COLGROUP':
case '+TBODY':
case '+TD':
case '+TFOOT':
case '+TH':
case '+THEAD':
case '+TR':
/*
* > Assert: The stack of open elements has a td or th element in table scope.
*
* Nothing to do here, except to verify in tests that this never appears.
*/
$this->close_cell();
return $this->step( self::REPROCESS_CURRENT_NODE );
/*
* > An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html"
*/
case '-BODY':
case '-CAPTION':
case '-COL':
case '-COLGROUP':
case '-HTML':
// Parse error: ignore the token.
return $this->step();
/*
* > An end tag whose tag name is one of: "table", "tbody", "tfoot", "thead", "tr"
*/
case '-TABLE':
case '-TBODY':
case '-TFOOT':
case '-THEAD':
case '-TR':
if ( ! $this->state->stack_of_open_elements->has_element_in_table_scope( $tag_name ) ) {
// Parse error: ignore the token.
return $this->step();
}
$this->close_cell();
return $this->step( self::REPROCESS_CURRENT_NODE );
}
/*
* > Anything else
* > Process the token using the rules for the "in body" insertion mode.
*/
return $this->step_in_body();
}