WP_HTML_Processor::run_adoption_agency_algorithm()

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. Use https://html.spec.whatwg.org/#adoption-agency-algorithm instead.

Runs the adoption agency algorithm.

Description

See also

Source

	return true;

/*
 * > An end tag whose tag name is "html"
 */
case '-HTML':
	if ( ! $this->state->stack_of_open_elements->has_element_in_scope( 'BODY' ) ) {
		// Parse error: ignore the token.
		return $this->step();
	}

	/*
	 * > Otherwise, if there is a node in the stack of open elements that is not either a
	 * > dd element, a dt element, an li element, an optgroup element, an option element,
	 * > a p element, an rb element, an rp element, an rt element, an rtc element, a tbody
	 * > element, a td element, a tfoot element, a th element, a thread element, a tr
	 * > element, the body element, or the html element, then this is a parse error.
	 *
	 * There is nothing to do for this parse error, so don't check for it.
	 */

	$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_BODY;
	return $this->step( self::REPROCESS_CURRENT_NODE );

/*
 * > A start tag whose tag name is one of: "address", "article", "aside",
 * > "blockquote", "center", "details", "dialog", "dir", "div", "dl",
 * > "fieldset", "figcaption", "figure", "footer", "header", "hgroup",
 * > "main", "menu", "nav", "ol", "p", "search", "section", "summary", "ul"
 */
case '+ADDRESS':
case '+ARTICLE':
case '+ASIDE':
case '+BLOCKQUOTE':
case '+CENTER':
case '+DETAILS':
case '+DIALOG':
case '+DIR':
case '+DIV':
case '+DL':
case '+FIELDSET':
case '+FIGCAPTION':
case '+FIGURE':
case '+FOOTER':
case '+HEADER':
case '+HGROUP':
case '+MAIN':
case '+MENU':
case '+NAV':
case '+OL':
case '+P':
case '+SEARCH':
case '+SECTION':
case '+SUMMARY':
case '+UL':
	if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
		$this->close_a_p_element();
	}

	$this->insert_html_element( $this->state->current_token );
	return true;

/*
 * > A start tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"
 */
case '+H1':
case '+H2':
case '+H3':
case '+H4':
case '+H5':
case '+H6':
	if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
		$this->close_a_p_element();
	}

	if (
		in_array(
			$this->state->stack_of_open_elements->current_node()->node_name,
			array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ),
			true
		)
	) {
		// @todo Indicate a parse error once it's possible.
		$this->state->stack_of_open_elements->pop();
	}

	$this->insert_html_element( $this->state->current_token );
	return true;

/*
 * > A start tag whose tag name is one of: "pre", "listing"
 */
case '+PRE':
case '+LISTING':
	if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
		$this->close_a_p_element();
	}

	/*
	 * > If the next token is a U+000A LINE FEED (LF) character token,
	 * > then ignore that token and move on to the next one. (Newlines

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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