Skip to content

Commit 9e66262

Browse files
committed
Expand documentation for qualified_tag_name()
1 parent 36776ce commit 9e66262

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,8 +2826,31 @@ public function get_tag(): ?string {
28262826
}
28272827

28282828
/**
2829-
* Returns the adjusted tag name for a given token, taking into
2830-
* account the current parsing context, whether HTML, SVG, or MathML.
2829+
* Returns the adjusted tag name for a displaying given tag name, taking
2830+
* into account the current parsing context, whether HTML, SVG, or MathML.
2831+
*
2832+
* Use this function when the purpose is displaying or printing HTML tags.
2833+
* For checking if a tag has a given name, rely on {@see static::get_tag}
2834+
* which takes HTML case-folding rules into account and always returns an
2835+
* ASCII upper-case variant of the matched tag name.
2836+
*
2837+
* Some SVG tags have specifically-called out case-folding rules, such as
2838+
* with `altGlyph`. These tags are normatively mixed-case.
2839+
*
2840+
* Example:
2841+
*
2842+
* $processor = new WP_HTML_Tag_Processor( '<div>' );
2843+
* $processor->next_tag();
2844+
* 'DIV' === $processor->get_tag();
2845+
* 'div' === $processor->get_qualified_tag_name();
2846+
*
2847+
* $processor = WP_HTML_Processor::create_fragment( '<svg><altglyph/><rect/></svg>' );
2848+
* $processor->next_tag( 'altglyph' );
2849+
* 'ALTGLYPH' === $processor->get_tag();
2850+
* 'altGlyph' === $processor->get_qualified_tag_name();
2851+
* $processor->next_tag();
2852+
* 'RECT' === $processor->get_tag();
2853+
* 'rect' === $processor->get_qualified_tag_name();
28312854
*
28322855
* @since 6.7.0
28332856
*

0 commit comments

Comments
 (0)