WP_HTML_Processor::step_after_body
Parses next element in the 'after body' insertion mode.
This internal function performs the 'after body' insertion mode logic for the generalized WP_HTML_Processor::step() function.
Method of the class: WP_HTML_Processor{}
No Hooks.
Returns
true|false. Whether an element was found.
Usage
// private - for code of main (parent) class only $result = $this->step_after_body(): bool;
Notes
Changelog
| Since 6.7.0 | Introduced. |
| Since 6.7.0 | Stub implementation. |
WP_HTML_Processor::step_after_body() WP HTML Processor::step after body code WP 6.9
private function step_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 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_body_anything_else;
break;
/*
* > A comment token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
$this->bail( 'Content outside of BODY is unsupported.' );
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 "html"
*
* > If the parser was created as part of the HTML fragment parsing algorithm,
* > this is a parse error; ignore the token. (fragment case)
* >
* > Otherwise, switch the insertion mode to "after after body".
*/
case '-HTML':
if ( isset( $this->context_node ) ) {
return $this->step();
}
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_AFTER_BODY;
/*
* The HTML element is not removed from the stack of open elements.
* Only internal state has changed, this does not qualify as a "step"
* in terms of advancing through the document to another token.
* Nothing has been pushed or popped.
* Proceed to parse the next item.
*/
return $this->step();
}
/*
* > Parse error. Switch the insertion mode to "in body" and reprocess the token.
*/
after_body_anything_else:
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_BODY;
return $this->step( self::REPROCESS_CURRENT_NODE );
}