WP_HTML_Processor::next_token(): bool

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Ensures internal accounting is maintained for HTML semantic rules while the underlying Tag Processor class is seeking to a bookmark.

Description

This doesn’t currently have a way to represent non-tags and doesn’t process semantic rules for text nodes. For access to the raw tokens consider using WP_HTML_Tag_Processor instead.

Return

bool

Source

		false
	);
	$fragment_processor->state->stack_of_open_elements->push( $root_node );

	$fragment_processor->bookmarks['context-node']   = new WP_HTML_Span( 0, 0 );
	$fragment_processor->context_node                = clone $this->current_element->token;
	$fragment_processor->context_node->bookmark_name = 'context-node';
	$fragment_processor->context_node->on_destroy    = null;

	$fragment_processor->breadcrumbs = array( 'HTML', $fragment_processor->context_node->node_name );

	if ( 'TEMPLATE' === $fragment_processor->context_node->node_name ) {
		$fragment_processor->state->stack_of_template_insertion_modes[] = WP_HTML_Processor_State::INSERTION_MODE_IN_TEMPLATE;
	}

	$fragment_processor->reset_insertion_mode_appropriately();

	/*
	 * > Set the parser's form element pointer to the nearest node to the context element that
	 * > is a form element (going straight up the ancestor chain, and including the element
	 * > itself, if it is a form element), if any. (If there is no such form element, the
	 * > form element pointer keeps its initial value, null.)
	 */
	foreach ( $this->state->stack_of_open_elements->walk_up() as $element ) {
		if ( 'FORM' === $element->node_name && 'html' === $element->namespace ) {
			$fragment_processor->state->form_element                = clone $element;
			$fragment_processor->state->form_element->bookmark_name = null;
			$fragment_processor->state->form_element->on_destroy    = null;
			break;
		}
	}

	$fragment_processor->state->encoding_confidence = 'irrelevant';

	/*
	 * Update the parsing namespace near the end of the process.
	 * This is important so that any push/pop from the stack of open
	 * elements does not change the parsing namespace.
	 */
	$fragment_processor->change_parsing_namespace(
		$this->current_element->token->integration_node_type ? 'html' : $namespace
	);

	return $fragment_processor;
}

/**
 * Stops the parser and terminates its execution when encountering unsupported markup.
 *
 * @throws WP_HTML_Unsupported_Exception Halts execution of the parser.

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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