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
| Version | Description |
|---|---|
| 6.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.