WP_HTML_Processor::step_in_head_noscript()privateWP 6.7.0

Parses next element in the 'in head noscript' insertion mode.

This internal function performs the 'in head noscript' insertion mode logic for the generalized WP_HTML_Processor::step() function.

Method of the class: WP_HTML_Processor{}

No Hooks.

Return

true|false. Whether an element was found.

Usage

// private - for code of main (parent) class only
$result = $this->step_in_head_noscript(): bool;

Notes

Changelog

Since 6.7.0 Introduced.
Since 6.7.0 Stub implementation.

WP_HTML_Processor::step_in_head_noscript() code WP 6.7.1

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

	switch ( $op ) {
		/*
		 * > 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
		 *
		 * Parse error: ignore the token.
		 */
		case '#text':
			if ( parent::TEXT_IS_WHITESPACE === $this->text_node_classification ) {
				return $this->step_in_head();
			}

			goto in_head_noscript_anything_else;
			break;

		/*
		 * > A DOCTYPE token
		 */
		case 'html':
			// Parse error: ignore the token.
			return $this->step();

		/*
		 * > A start tag whose tag name is "html"
		 */
		case '+HTML':
			return $this->step_in_body();

		/*
		 * > An end tag whose tag name is "noscript"
		 */
		case '-NOSCRIPT':
			$this->state->stack_of_open_elements->pop();
			$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_HEAD;
			return true;

		/*
		 * > A comment token
		 * >
		 * > A start tag whose tag name is one of: "basefont", "bgsound",
		 * > "link", "meta", "noframes", "style"
		 */
		case '#comment':
		case '#funky-comment':
		case '#presumptuous-tag':
		case '+BASEFONT':
		case '+BGSOUND':
		case '+LINK':
		case '+META':
		case '+NOFRAMES':
		case '+STYLE':
			return $this->step_in_head();

		/*
		 * > An end tag whose tag name is "br"
		 *
		 * This should never happen, as the Tag Processor prevents showing a BR closing tag.
		 */
	}

	/*
	 * > A start tag whose tag name is one of: "head", "noscript"
	 * > Any other end tag
	 */
	if ( '+HEAD' === $op || '+NOSCRIPT' === $op || $is_closer ) {
		// Parse error: ignore the token.
		return $this->step();
	}

	/*
	 * > Anything else
	 *
	 * Anything here is a parse error.
	 */
	in_head_noscript_anything_else:
	$this->state->stack_of_open_elements->pop();
	$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_HEAD;
	return $this->step( self::REPROCESS_CURRENT_NODE );
}