From 2b781bee56253629f0d0e610a34e01d87badb8cc Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 19 Jan 2024 16:53:25 -0700 Subject: [PATCH] HTML API: Cleanup tests and list of void elements. This patch adds newly supported elements to tests that should have been updated in recent PRs, but which were merged without that. Those PRs removed failing tests showing that the elements were unsupported, but did not add the elements to the list of supported ones. It also removes some elements from the special-exclusion list of unsupported IN BODY elements. These did not present in failing tests because earlier conditions in the switch structure caught the tags before hitting the default block. Finally it adds some missing elements to the list of void elements. These elements are not listed as void in the HTML specification because they are deprecated. However, they are treated as void for the sake of HTML serialization and the parsing rules indicate that they behave as void elements, so it's safe to list them within the HTML API as void. --- .../html-api/class-wp-html-processor.php | 10 ++++------ .../tests/html-api/wpHtmlProcessorBreadcrumbs.php | 14 ++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 65fcfbe236ee5..58d34b2833eaa 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -1002,7 +1002,6 @@ private function step_in_body() { */ switch ( $tag_name ) { case 'APPLET': - case 'AREA': case 'BASE': case 'BASEFONT': case 'BGSOUND': @@ -1010,8 +1009,6 @@ private function step_in_body() { case 'CAPTION': case 'COL': case 'COLGROUP': - case 'DD': - case 'DT': case 'FORM': case 'FRAME': case 'FRAMESET': @@ -1019,7 +1016,6 @@ private function step_in_body() { case 'HTML': case 'IFRAME': case 'INPUT': - case 'LI': case 'LINK': case 'MARQUEE': case 'MATH': @@ -1029,7 +1025,6 @@ private function step_in_body() { case 'NOFRAMES': case 'NOSCRIPT': case 'OBJECT': - case 'OL': case 'OPTGROUP': case 'OPTION': case 'PARAM': @@ -1055,7 +1050,6 @@ private function step_in_body() { case 'TITLE': case 'TR': case 'TRACK': - case 'UL': case 'XMP': $this->last_error = self::ERROR_UNSUPPORTED; throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." ); @@ -1709,15 +1703,19 @@ public static function is_void( $tag_name ) { return ( 'AREA' === $tag_name || 'BASE' === $tag_name || + 'BASEFONT' === $tag_name || // Obsolete but still treated as void. + 'BGSOUND' === $tag_name || // Obsolete but still treated as void. 'BR' === $tag_name || 'COL' === $tag_name || 'EMBED' === $tag_name || + 'FRAME' === $tag_name || 'HR' === $tag_name || 'IMG' === $tag_name || 'INPUT' === $tag_name || 'LINK' === $tag_name || 'KEYGEN' === $tag_name || // Obsolete but still treated as void. 'META' === $tag_name || + 'PARAM' === $tag_name || // Obsolete but still treated as void. 'SOURCE' === $tag_name || 'TRACK' === $tag_name || 'WBR' === $tag_name diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php index 4e769ab2ca293..02098f2300d5f 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php @@ -40,6 +40,7 @@ public function data_single_tag_of_supported_elements() { 'ABBR', 'ACRONYM', // Neutralized. 'ADDRESS', + 'AREA', 'ARTICLE', 'ASIDE', 'AUDIO', @@ -48,6 +49,7 @@ public function data_single_tag_of_supported_elements() { 'BDO', 'BIG', 'BLINK', // Deprecated. + 'BR', 'BUTTON', 'CANVAS', 'CENTER', // Neutralized. @@ -65,6 +67,7 @@ public function data_single_tag_of_supported_elements() { 'DL', 'DT', 'EM', + 'EMBED', 'FIELDSET', 'FIGCAPTION', 'FIGURE', @@ -78,22 +81,25 @@ public function data_single_tag_of_supported_elements() { 'H6', 'HEADER', 'HGROUP', + 'HR', 'I', 'IMG', 'INS', 'LI', - 'ISINDEX', // Deprecated + 'ISINDEX', // Deprecated. 'KBD', + 'KEYGEN', // Deprecated. 'LABEL', 'LEGEND', + 'LISTING', // Deprecated. 'MAIN', 'MAP', 'MARK', 'MENU', 'METER', - 'MULTICOL', // Deprecated + 'MULTICOL', // Deprecated. 'NAV', - 'NEXTID', // Deprecated + 'NEXTID', // Deprecated. 'OL', 'OUTPUT', 'P', @@ -106,7 +112,7 @@ public function data_single_tag_of_supported_elements() { 'SECTION', 'SLOT', 'SMALL', - 'SPACER', // Deprecated + 'SPACER', // Deprecated. 'SPAN', 'STRIKE', 'STRONG',