WP_HTML_Processor::step_in_cell(): bool

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Parses next element in the ‘in cell’ insertion mode.

Description

This internal function performs the ‘in cell’ insertion mode logic for the generalized WP_HTML_Processor::step() function.

See also

Return

bool Whether an element was found.

Source

	}
	$this->state->stack_of_open_elements->pop();
	$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_TABLE;
	return $this->step( self::REPROCESS_CURRENT_NODE );
}

/**
 * Parses next element in the 'in table body' insertion mode.
 *
 * This internal function performs the 'in table body' insertion mode
 * logic for the generalized WP_HTML_Processor::step() function.
 *
 * @since 6.7.0
 * @ignore
 *
 * @throws WP_HTML_Unsupported_Exception When encountering unsupported HTML input.
 *
 * @see https://html.spec.whatwg.org/#parsing-main-intbody
 * @see WP_HTML_Processor::step
 *
 * @return bool Whether an element was found.
 */
private function step_in_table_body(): bool {
	$tag_name = $this->get_tag();
	$op_sigil = $this->is_tag_closer() ? '-' : '+';
	$op       = "{$op_sigil}{$tag_name}";

	switch ( $op ) {
		/*
		 * > A start tag whose tag name is "tr"
		 */
		case '+TR':
			$this->state->stack_of_open_elements->clear_to_table_body_context();
			$this->insert_html_element( $this->state->current_token );
			$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_ROW;
			return true;

		/*
		 * > A start tag whose tag name is one of: "th", "td"
		 */
		case '+TH':
		case '+TD':
			// @todo Indicate a parse error once it's possible.
			$this->state->stack_of_open_elements->clear_to_table_body_context();
			$this->insert_virtual_node( 'TR' );
			$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_ROW;
			return $this->step( self::REPROCESS_CURRENT_NODE );

		/*
		 * > An end tag whose tag name is one of: "tbody", "tfoot", "thead"
		 */
		case '-TBODY':
		case '-TFOOT':
		case '-THEAD':
			if ( ! $this->state->stack_of_open_elements->has_element_in_table_scope( $tag_name ) ) {
				// Parse error: ignore the token.
				return $this->step();
			}

			$this->state->stack_of_open_elements->clear_to_table_body_context();
			$this->state->stack_of_open_elements->pop();
			$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_TABLE;
			return true;

		/*
		 * > A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "tfoot", "thead"
		 * > An end tag whose tag name is "table"
		 */
		case '+CAPTION':
		case '+COL':
		case '+COLGROUP':
		case '+TBODY':
		case '+TFOOT':
		case '+THEAD':
		case '-TABLE':
			if (
				! $this->state->stack_of_open_elements->has_element_in_table_scope( 'TBODY' ) &&
				! $this->state->stack_of_open_elements->has_element_in_table_scope( 'THEAD' ) &&
				! $this->state->stack_of_open_elements->has_element_in_table_scope( 'TFOOT' )
			) {
				// Parse error: ignore the token.
				return $this->step();
			}
			$this->state->stack_of_open_elements->clear_to_table_body_context();
			$this->state->stack_of_open_elements->pop();
			$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_TABLE;
			return $this->step( self::REPROCESS_CURRENT_NODE );

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.