WP_HTML_Processor::insert_foreign_element()privateWP 6.7.0

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

Метод класса: WP_HTML_Processor{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->insert_foreign_element( $token, $only_add_to_element_stack ): void;
$token(WP_HTML_Token) (обязательный)
Insert this token. The token's namespace and insertion point will be updated correctly.
$only_add_to_element_stack(true|false) (обязательный)
Whether to skip the "insert an element at the adjusted insertion location" algorithm when adding this element.

Заметки

Список изменений

С версии 6.7.0 Введена.

Код WP_HTML_Processor::insert_foreign_element() WP 6.7.1

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 );
}