WP_HTML_Processor::insert_foreign_element
Inserts a foreign element on to the stack of open elements.
Method of the class: WP_HTML_Processor{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->insert_foreign_element( $token, $only_add_to_element_stack ): void;
- $token(WP_HTML_Token) (required)
- Insert this token. The token's namespace and insertion point will be updated correctly.
- $only_add_to_element_stack(true|false) (required)
- Whether to skip the "insert an element at the adjusted insertion location" algorithm when adding this element.
Notes
Changelog
| Since 6.7.0 | Introduced. |
WP_HTML_Processor::insert_foreign_element() WP HTML Processor::insert foreign element code WP 6.9
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 );
}