WP_HTML_Processor::insert_foreign_element( WP_HTML_Token $token, bool $only_add_to_element_stack )

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.

Inserts a foreign element on to the stack of open elements.

Description

See also

Parameters

$tokenWP_HTML_Tokenrequired
Insert this token. The token’s namespace and insertion point will be updated correctly.
$only_add_to_element_stackboolrequired
Whether to skip the "insert an element at the adjusted insertion location" algorithm when adding this element.

Source

private function insert_foreign_element( WP_HTML_Token $token, bool $only_add_to_element_stack ): void {
	$adjusted_current_node = $this->get_adjusted_current_node();

	$token->namespace = $adjusted_current_node ? $adjusted_current_node->namespace : 'html';

	if ( $this->is_mathml_integration_point() ) {
		$token->integration_node_type = 'math';
	} elseif ( $this->is_html_integration_point() ) {
		$token->integration_node_type = 'html';
	}

	if ( false === $only_add_to_element_stack ) {
		/*
		 * @todo Implement the "appropriate place for inserting a node" and the
		 *       "insert an element at the adjusted insertion location" algorithms.
		 *
		 * These algorithms mostly impacts DOM tree construction and not the HTML API.
		 * Here, there's no DOM node onto which the element will be appended, so the
		 * parser will skip this step.
		 *
		 * @see https://html.spec.whatwg.org/#insert-an-element-at-the-adjusted-insertion-location
		 */
	}

	$this->insert_html_element( $token );
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

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