Skip to content

Commit

Permalink
Extract block tags to a private class constant and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mundschenk-at committed Mar 30, 2024
1 parent 35c2f1e commit d57030a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/class-dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,23 @@ abstract class DOM {
*/
private static array $inappropriate_tags;

const ADDITIONAL_INAPPROPRIATE_TAGS = [
/**
* Block tags not included as such in the current HTML5-PHP version.
*
* @since 7.0.0
*/
private const ADDITIONAL_BLOCK_TAGS = [
'li',
'td',
'dt',
];

/**
* Tags that should never be modified.
*
* @since 5.2.0
*/
private const ADDITIONAL_INAPPROPRIATE_TAGS = [
'button',
'select',
'optgroup',
Expand Down Expand Up @@ -94,16 +110,16 @@ abstract class DOM {
*/
public static function block_tags( bool $reset = false ): array {
if ( empty( self::$block_tags ) || $reset ) {
self::$block_tags = \array_merge(
\array_flip(
self::$block_tags = \array_flip(
\array_merge(
\array_filter(
\array_keys( Elements::$html5 ),
function ( $tag ) {
return Elements::isA( $tag, Elements::BLOCK_TAG );
}
)
),
\array_flip( [ 'li', 'td', 'dt' ] ) // not included as "block tags" in current HTML5-PHP version.
),
self::ADDITIONAL_BLOCK_TAGS
)
);
}

Expand Down

0 comments on commit d57030a

Please sign in to comment.