Returns the uppercase name of the matched tag.
Description
The semantic rules for HTML specify that certain tags be reprocessed with a different tag name. Because of this, the tag name presented by the HTML Processor may differ from the one reported by the HTML Tag Processor, which doesn’t apply these semantic rules.
Example:
$processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
$processor->next_tag() === true;
$processor->get_tag() === 'DIV';
$processor->next_tag() === false;
$processor->get_tag() === null;
Source
* @since 6.7.0
*
* @throws WP_HTML_Unsupported_Exception When encountering unsupported HTML input.
*
* @see https://html.spec.whatwg.org/#the-before-html-insertion-mode
* @see WP_HTML_Processor::step
*
* @return bool Whether an element was found.
*/
private function step_before_html(): 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 DOCTYPE token
*/
case 'html':
// Parse error: ignore the token.
return $this->step();
Changelog
Version | Description |
---|---|
6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.