WP_HTML_Processor::step_after_after_body(): bool

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

Parses next element in the ‘after after body’ insertion mode.

Description

This internal function performs the ‘after after body’ insertion mode logic for the generalized WP_HTML_Processor::step() function.

See also

Return

bool Whether an element was found.

Source

private function step_after_after_body(): bool {
	$tag_name   = $this->get_token_name();
	$token_type = $this->get_token_type();
	$op_sigil   = '#tag' === $token_type ? ( $this->is_tag_closer() ? '-' : '+' ) : '';
	$op         = "{$op_sigil}{$tag_name}";

	switch ( $op ) {
		/*
		 * > A comment token
		 */
		case '#comment':
		case '#funky-comment':
		case '#presumptuous-tag':
			$this->bail( 'Content outside of HTML is unsupported.' );
			break;

		/*
		 * > A DOCTYPE token
		 * > A start tag whose tag name is "html"
		 *
		 * > Process the token using the rules for the "in body" insertion mode.
		 */
		case 'html':
		case '+HTML':
			return $this->step_in_body();

		/*
		 * > A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF),
		 * >   U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE
		 * >
		 * > Process the token using the rules for the "in body" insertion mode.
		 */
		case '#text':
			if ( parent::TEXT_IS_WHITESPACE === $this->text_node_classification ) {
				return $this->step_in_body();
			}
			goto after_after_body_anything_else;
			break;
	}

	/*
	 * > Parse error. Switch the insertion mode to "in body" and reprocess the token.
	 */
	after_after_body_anything_else:
	$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_BODY;
	return $this->step( self::REPROCESS_CURRENT_NODE );
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

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