Skip to content

Commit

Permalink
Reuse WP_HTML_Processor::is_void()
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Apr 6, 2024
1 parent 357b3ce commit 34b6a27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
34 changes: 2 additions & 32 deletions plugins/optimization-detective/class-od-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,6 @@
*/
final class OD_HTML_Tag_Processor {

/**
* HTML void tags (i.e. those which are self-closing).
*
* @link https://html.spec.whatwg.org/multipage/syntax.html#void-elements
* @see WP_HTML_Processor::is_void()
* @todo Reuse `WP_HTML_Processor::is_void()` once WordPress 6.4 is the minimum-supported version.
*
* @var string[]
*/
const VOID_TAGS = array(
'AREA',
'BASE',
'BASEFONT', // Obsolete.
'BGSOUND', // Obsolete.
'BR',
'COL',
'EMBED',
'FRAME', // Deprecated.
'HR',
'IMG',
'INPUT',
'KEYGEN', // Obsolete.
'LINK',
'META',
'PARAM', // Deprecated.
'SOURCE',
'TRACK',
'WBR',
);

/**
* Raw text tags.
*
Expand Down Expand Up @@ -225,7 +195,7 @@ public function open_tags(): Generator {

// Immediately pop off self-closing and raw text tags.
if (
in_array( $tag_name, self::VOID_TAGS, true )
WP_HTML_Processor::is_void( $tag_name )
||
in_array( $tag_name, self::RAW_TEXT_TAGS, true )
||
Expand All @@ -236,7 +206,7 @@ public function open_tags(): Generator {
} else {
// If the closing tag is for self-closing or raw text tag, we ignore it since it was already handled above.
if (
in_array( $tag_name, self::VOID_TAGS, true )
WP_HTML_Processor::is_void( $tag_name )
||
in_array( $tag_name, self::RAW_TEXT_TAGS, true )
) {
Expand Down
1 change: 1 addition & 0 deletions plugins/optimization-detective/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ The [plugin source code](https://github.com/WordPress/performance/tree/trunk/plu
= 0.1.1 =

* Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103))
* Reuse `WP_HTML_Processor::is_void()` now that WP 6.4 is minimum supported version. ([1115](https://github.com/WordPress/performance/pull/1115))

= 0.1.0 =

Expand Down

0 comments on commit 34b6a27

Please sign in to comment.