WordPress/wp-includes/html-api
Bernhard Reiter 2d9b5cb098 HTML API: Add class name utilities has_class() and class_list().
This patch adds two new public methods to the HTML Tag Processor:
 - `has_class()` indicates if a matched tag contains a given CSS class name.
 - `class_list()` returns a generator to iterate over all the class names in a matched tag.

Included in this patch is a refactoring of the internal logic when matching
a tag to reuse the new `has_class()` function. Previously it was relying on
optimized code in the `matches()` function which performed byte-for-byte
class name comparison. With the change in this patch it will perform class
name matching on the decoded value, which might differ if a class attribute
contains character references.

These methods may be useful for running more complicated queries based
on the presence or absence of CSS class names. The use of these methods
avoids the need to manually decode the class attribute as reported by
`$process->get_attribute( 'class' )`.

Props dmsnell.
Fixes #59209.
Built from https://develop.svn.wordpress.org/trunk@56703


git-svn-id: http://core.svn.wordpress.org/trunk@56215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 09:17:18 +00:00
..
class-wp-html-active-formatting-elements.php HTML API: Adjust code styling to Gutenberg's linter's preferences. 2023-08-07 13:50:27 +00:00
class-wp-html-attribute-token.php Docs: Improve HTML API file and class headers per the documentation standards. 2023-05-09 11:19:21 +00:00
class-wp-html-open-elements.php HTML API: Add support for BUTTON element. 2023-08-10 08:37:20 +00:00
class-wp-html-processor-state.php HTML API: Store current token reference in HTML Processor state. 2023-09-12 15:12:17 +00:00
class-wp-html-processor.php HTML API: Add matches_breadcrumbs() method for better querying. 2023-09-26 08:20:17 +00:00
class-wp-html-span.php Docs: Improve HTML API file and class headers per the documentation standards. 2023-05-09 11:19:21 +00:00
class-wp-html-tag-processor.php HTML API: Add class name utilities has_class() and class_list(). 2023-09-26 09:17:18 +00:00
class-wp-html-text-replacement.php Docs: Improve HTML API file and class headers per the documentation standards. 2023-05-09 11:19:21 +00:00
class-wp-html-token.php HTML API: Adjust code styling to Gutenberg's linter's preferences. 2023-08-07 13:50:27 +00:00
class-wp-html-unsupported-exception.php HTML-API: Introduce minimal HTML Processor. 2023-07-20 13:43:25 +00:00