WP_HTML_Processor::step_in_frameset(): bool

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/#parsing-main-inframeset instead.

Parses next element in the ‘in frameset’ insertion mode.

Description

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

See also

Return

bool Whether an element was found.

Source

private function step_in_frameset(): 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 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
		 * >
		 * > Insert the character.
		 *
		 * This algorithm effectively strips non-whitespace characters from text and inserts
		 * them under HTML. This is not supported at this time.
		 */
		case '#text':
			if ( parent::TEXT_IS_WHITESPACE === $this->text_node_classification ) {
				return $this->step_in_body();
			}
			$this->bail( 'Non-whitespace characters cannot be handled in frameset.' );
			break;

		/*
		 * > A comment token
		 */
		case '#comment':
		case '#funky-comment':
		case '#presumptuous-tag':
			$this->insert_html_element( $this->state->current_token );
			return true;

		/*
		 * > 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();

		/*
		 * > A start tag whose tag name is "frameset"
		 */
		case '+FRAMESET':
			$this->insert_html_element( $this->state->current_token );
			return true;

		/*
		 * > An end tag whose tag name is "frameset"
		 */
		case '-FRAMESET':
			/*
			 * > If the current node is the root html element, then this is a parse error;
			 * > ignore the token. (fragment case)
			 */
			if ( $this->state->stack_of_open_elements->current_node_is( 'HTML' ) ) {
				return $this->step();
			}

			/*
			 * > Otherwise, pop the current node from the stack of open elements.
			 */
			$this->state->stack_of_open_elements->pop();

			/*
			 * > If the parser was not created as part of the HTML fragment parsing algorithm
			 * > (fragment case), and the current node is no longer a frameset element, then
			 * > switch the insertion mode to "after frameset".
			 */
			if ( ! isset( $this->context_node ) && ! $this->state->stack_of_open_elements->current_node_is( 'FRAMESET' ) ) {
				$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_FRAMESET;
			}

			return true;

		/*
		 * > A start tag whose tag name is "frame"
		 *
		 * > Insert an HTML element for the token. Immediately pop the
		 * > current node off the stack of open elements.
		 * >
		 * > Acknowledge the token's self-closing flag, if it is set.
		 */
		case '+FRAME':
			$this->insert_html_element( $this->state->current_token );
			$this->state->stack_of_open_elements->pop();
			return true;

		/*
		 * > A start tag whose tag name is "noframes"
		 */
		case '+NOFRAMES':
			return $this->step_in_head();
	}

	// Parse error: ignore the token.
	return $this->step();
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

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