WP_HTML_Processor::insert_virtual_node()privateWP 6.7.0

Inserts a virtual element on the stack of open elements.

Method of the class: WP_HTML_Processor{}

No Hooks.

Return

WP_HTML_Token. Newly-created virtual token.

Usage

// private - for code of main (parent) class only
$result = $this->insert_virtual_node( $token_name, $bookmark_name ): WP_HTML_Token;
$token_name(string) (required)
Name of token to create and insert into the stack of open elements.
$bookmark_name(string|null)
Name to give bookmark for created virtual node.
Default: auto-creating a bookmark name

Changelog

Since 6.7.0 Introduced.

WP_HTML_Processor::insert_virtual_node() code WP 6.7.1

private function insert_virtual_node( $token_name, $bookmark_name = null ): WP_HTML_Token {
	$here = $this->bookmarks[ $this->state->current_token->bookmark_name ];
	$name = $bookmark_name ?? $this->bookmark_token();

	$this->bookmarks[ $name ] = new WP_HTML_Span( $here->start, 0 );

	$token = new WP_HTML_Token( $name, $token_name, false );
	$this->insert_html_element( $token );
	return $token;
}