WP_HTML_Processor::step_initial
Parses next element in the 'initial' insertion mode.
This internal function performs the 'initial' insertion mode logic for the generalized WP_HTML_Processor::step() function.
Метод класса: WP_HTML_Processor{}
Хуков нет.
Возвращает
true|false. Whether an element was found.
Использование
// private - только в коде основоного (родительского) класса $result = $this->step_initial(): bool;
Заметки
- Смотрите: https://html.spec.whatwg.org/#the-initial-insertion-mode
- Смотрите: WP_HTML_Processor::step
Список изменений
| С версии 6.7.0 | Введена. |
Код WP_HTML_Processor::step_initial() WP HTML Processor::step initial WP 6.9
private function step_initial(): bool {
$token_name = $this->get_token_name();
$token_type = $this->get_token_type();
$op_sigil = '#tag' === $token_type ? ( parent::is_tag_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();
}
goto initial_anything_else;
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':
$doctype = $this->get_doctype_info();
if ( null !== $doctype && 'quirks' === $doctype->indicated_compatibility_mode ) {
$this->compat_mode = WP_HTML_Tag_Processor::QUIRKS_MODE;
}
/*
* > Then, switch the insertion mode to "before html".
*/
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_BEFORE_HTML;
$this->insert_html_element( $this->state->current_token );
return true;
}
/*
* > Anything else
*/
initial_anything_else:
$this->compat_mode = WP_HTML_Tag_Processor::QUIRKS_MODE;
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_BEFORE_HTML;
return $this->step( self::REPROCESS_CURRENT_NODE );
}