<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[57115] trunk: HTML API: Add support for containers elements, including ARTICLE.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57115">57115</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57115","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>Bernhard Reiter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-11-17 06:11:31 +0000 (Fri, 17 Nov 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>HTML API: Add support for containers elements, including ARTICLE.
There are a handful of elements which behave similarly and are generically container elements. These are the following elements:
ADDRESS, ARTICLE, ASIDE, BLOCKQUOTE, CENTER, DETAILS, DIALOG, DIR,
DL, DIV, FIELDSET, FIGCAPTION, FIGURE, FOOTER, HEADER, HGROUP, MAIN,
MENU, NAV, SEARCH, SECTION, SUMMARY
This patch adds support to the HTML Processor for handling these elements. They do not require any additional logic in the rest of the class, and carry no specific semantic rules for parsing beyond what is listed in their group in the IN BODY section of the HTML5 specification.
Props dmsnell.
Fixes <a href="https://core.trac.wordpress.org/ticket/59914">#59914</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludeshtmlapiclasswphtmlprocessorphp">trunk/src/wp-includes/html-api/class-wp-html-processor.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlProcessorBreadcrumbsphp">trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlProcessorSemanticRulesphp">trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludeshtmlapiclasswphtmlprocessorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/html-api/class-wp-html-processor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/html-api/class-wp-html-processor.php 2023-11-16 17:00:28 UTC (rev 57114)
+++ trunk/src/wp-includes/html-api/class-wp-html-processor.php 2023-11-17 06:11:31 UTC (rev 57115)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,12 +99,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The following list specifies the HTML tags that _are_ supported:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * - Containers: ADDRESS, BLOCKQUOTE, DETAILS, DIALOG, DIV, FOOTER, HEADER, MAIN, MENU, SPAN, SUMMARY.
+ * - Form elements: BUTTON, FIELDSET, SEARCH.
+ * - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U.
+ * - Heading elements: HGROUP.
</ins><span class="cx" style="display: block; padding: 0 10px"> * - Links: A.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * - The formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U.
- * - Containers: DIV, FIGCAPTION, FIGURE, SPAN.
- * - Form elements: BUTTON.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * - Lists: DL.
+ * - Media elements: FIGCAPTION, FIGURE, IMG.
</ins><span class="cx" style="display: block; padding: 0 10px"> * - Paragraph: P.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * - Void elements: IMG.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION
+ * - Deprecated elements: CENTER, DIR
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * ### Supported markup
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -621,11 +625,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * > "fieldset", "figcaption", "figure", "footer", "header", "hgroup",
</span><span class="cx" style="display: block; padding: 0 10px"> * > "main", "menu", "nav", "ol", "p", "search", "section", "summary", "ul"
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '+ADDRESS':
+ case '+ARTICLE':
+ case '+ASIDE':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '+BLOCKQUOTE':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '+CENTER':
+ case '+DETAILS':
+ case '+DIALOG':
+ case '+DIR':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '+DIV':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '+DL':
+ case '+FIELDSET':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '+FIGCAPTION':
</span><span class="cx" style="display: block; padding: 0 10px"> case '+FIGURE':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '+FOOTER':
+ case '+HEADER':
+ case '+HGROUP':
+ case '+MAIN':
+ case '+MENU':
+ case '+NAV':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '+P':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '+SEARCH':
+ case '+SECTION':
+ case '+SUMMARY':
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->close_a_p_element();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -639,11 +661,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * > "figcaption", "figure", "footer", "header", "hgroup", "listing", "main",
</span><span class="cx" style="display: block; padding: 0 10px"> * > "menu", "nav", "ol", "pre", "search", "section", "summary", "ul"
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '-ADDRESS':
+ case '-ARTICLE':
+ case '-ASIDE':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '-BLOCKQUOTE':
</span><span class="cx" style="display: block; padding: 0 10px"> case '-BUTTON':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '-CENTER':
+ case '-DETAILS':
+ case '-DIALOG':
+ case '-DIR':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '-DIV':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '-DL':
+ case '-FIELDSET':
</ins><span class="cx" style="display: block; padding: 0 10px"> case '-FIGCAPTION':
</span><span class="cx" style="display: block; padding: 0 10px"> case '-FIGURE':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case '-FOOTER':
+ case '-HEADER':
+ case '-HGROUP':
+ case '-MAIN':
+ case '-MENU':
+ case '-NAV':
+ case '-SEARCH':
+ case '-SECTION':
+ case '-SUMMARY':
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->state->stack_of_open_elements->has_element_in_scope( $tag_name ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // @TODO: Report parse error.
</span><span class="cx" style="display: block; padding: 0 10px"> // Ignore the token.
</span></span></pre></div>
<a id="trunktestsphpunittestshtmlapiwpHtmlProcessorBreadcrumbsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php 2023-11-16 17:00:28 UTC (rev 57114)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php 2023-11-17 06:11:31 UTC (rev 57115)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -37,22 +37,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function data_single_tag_of_supported_elements() {
</span><span class="cx" style="display: block; padding: 0 10px"> $supported_elements = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'A',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'ADDRESS',
+ 'ARTICLE',
+ 'ASIDE',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'B',
</span><span class="cx" style="display: block; padding: 0 10px"> 'BIG',
</span><span class="cx" style="display: block; padding: 0 10px"> 'BUTTON',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'CENTER', // Neutralized
</ins><span class="cx" style="display: block; padding: 0 10px"> 'CODE',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'DETAILS',
+ 'DIALOG',
+ 'DIR',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'DIV',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'DL',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'EM',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'FIELDSET',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'FIGCAPTION',
</span><span class="cx" style="display: block; padding: 0 10px"> 'FIGURE',
</span><span class="cx" style="display: block; padding: 0 10px"> 'FONT',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'FOOTER',
+ 'HEADER',
+ 'HGROUP',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'I',
</span><span class="cx" style="display: block; padding: 0 10px"> 'IMG',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'MAIN',
+ 'MENU',
+ 'NAV',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'P',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'SEARCH',
+ 'SECTION',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'SMALL',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SPAN',
</span><span class="cx" style="display: block; padding: 0 10px"> 'STRIKE',
</span><span class="cx" style="display: block; padding: 0 10px"> 'STRONG',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'SUMMARY',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'TT',
</span><span class="cx" style="display: block; padding: 0 10px"> 'U',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,11 +117,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $unsupported_elements = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ABBR',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ACRONYM', // Neutralized
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'ADDRESS',
</del><span class="cx" style="display: block; padding: 0 10px"> 'APPLET', // Deprecated
</span><span class="cx" style="display: block; padding: 0 10px"> 'AREA',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'ARTICLE',
- 'ASIDE',
</del><span class="cx" style="display: block; padding: 0 10px"> 'AUDIO',
</span><span class="cx" style="display: block; padding: 0 10px"> 'BASE',
</span><span class="cx" style="display: block; padding: 0 10px"> 'BDI',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,7 +129,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'BR',
</span><span class="cx" style="display: block; padding: 0 10px"> 'CANVAS',
</span><span class="cx" style="display: block; padding: 0 10px"> 'CAPTION',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'CENTER', // Neutralized
</del><span class="cx" style="display: block; padding: 0 10px"> 'CITE',
</span><span class="cx" style="display: block; padding: 0 10px"> 'COL',
</span><span class="cx" style="display: block; padding: 0 10px"> 'COLGROUP',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,14 +136,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'DATALIST',
</span><span class="cx" style="display: block; padding: 0 10px"> 'DD',
</span><span class="cx" style="display: block; padding: 0 10px"> 'DEL',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'DETAILS',
</del><span class="cx" style="display: block; padding: 0 10px"> 'DEFN',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'DIALOG',
- 'DL',
</del><span class="cx" style="display: block; padding: 0 10px"> 'DT',
</span><span class="cx" style="display: block; padding: 0 10px"> 'EMBED',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'FIELDSET',
- 'FOOTER',
</del><span class="cx" style="display: block; padding: 0 10px"> 'FORM',
</span><span class="cx" style="display: block; padding: 0 10px"> 'FRAME',
</span><span class="cx" style="display: block; padding: 0 10px"> 'FRAMESET',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -140,8 +149,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'H5',
</span><span class="cx" style="display: block; padding: 0 10px"> 'H6',
</span><span class="cx" style="display: block; padding: 0 10px"> 'HEAD',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'HEADER',
- 'HGROUP',
</del><span class="cx" style="display: block; padding: 0 10px"> 'HR',
</span><span class="cx" style="display: block; padding: 0 10px"> 'HTML',
</span><span class="cx" style="display: block; padding: 0 10px"> 'IFRAME',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,16 +162,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'LI',
</span><span class="cx" style="display: block; padding: 0 10px"> 'LINK',
</span><span class="cx" style="display: block; padding: 0 10px"> 'LISTING', // Deprecated, use PRE instead.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'MAIN',
</del><span class="cx" style="display: block; padding: 0 10px"> 'MAP',
</span><span class="cx" style="display: block; padding: 0 10px"> 'MARK',
</span><span class="cx" style="display: block; padding: 0 10px"> 'MARQUEE', // Deprecated
</span><span class="cx" style="display: block; padding: 0 10px"> 'MATH',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'MENU',
</del><span class="cx" style="display: block; padding: 0 10px"> 'META',
</span><span class="cx" style="display: block; padding: 0 10px"> 'METER',
</span><span class="cx" style="display: block; padding: 0 10px"> 'MULTICOL', // Deprecated
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'NAV',
</del><span class="cx" style="display: block; padding: 0 10px"> 'NEXTID', // Deprecated
</span><span class="cx" style="display: block; padding: 0 10px"> 'NOBR', // Neutralized
</span><span class="cx" style="display: block; padding: 0 10px"> 'NOEMBED', // Neutralized
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -187,7 +191,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'RUBY',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SAMP',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SCRIPT',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'SECTION',
</del><span class="cx" style="display: block; padding: 0 10px"> 'SELECT',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SLOT',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SOURCE',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,7 +197,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'SPACER', // Deprecated
</span><span class="cx" style="display: block; padding: 0 10px"> 'STYLE',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SUB',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'SUMMARY',
</del><span class="cx" style="display: block; padding: 0 10px"> 'SUP',
</span><span class="cx" style="display: block; padding: 0 10px"> 'SVG',
</span><span class="cx" style="display: block; padding: 0 10px"> 'TABLE',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -348,6 +350,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'HTML', 'BODY', 'DIV', 'DIV', 'DIV', 'DIV', 'DIV', 'DIV', 'DIV', 'DIV', 'DIV', 'STRONG', 'EM', 'CODE' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 2,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'MAIN inside MAIN inside SPAN' => array( '<span><main><main target>', array( 'HTML', 'BODY', 'SPAN', 'MAIN', 'MAIN' ), 1 ),
+ 'MAIN next to unclosed P' => array( '<p><main target>', array( 'HTML', 'BODY', 'MAIN' ), 1 ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestshtmlapiwpHtmlProcessorSemanticRulesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php 2023-11-16 17:00:28 UTC (rev 57114)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php 2023-11-17 06:11:31 UTC (rev 57115)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,6 +17,105 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *******************************************************************/
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Verifies that tags in the container group, including the ARTICLE element,
+ * close out an open P element if one exists.
+ *
+ * @covers WP_HTML_Processor::step_in_body
+ *
+ * @ticket 59914
+ *
+ * @dataProvider data_article_container_group
+ *
+ * @param string $tag_name Name of tag in group under test.
+ */
+ public function test_in_body_article_group_closes_open_p_element( $tag_name ) {
+ $processor = WP_HTML_Processor::create_fragment( "<p><p><p><p><{$tag_name} target>" );
+
+ while ( $processor->next_tag() && null === $processor->get_attribute( 'target' ) ) {
+ continue;
+ }
+
+ $this->assertEquals(
+ $tag_name,
+ $processor->get_tag(),
+ "Expected to find {$tag_name} but found {$processor->get_tag()} instead."
+ );
+
+ $this->assertSame(
+ array( 'HTML', 'BODY', $tag_name ),
+ $processor->get_breadcrumbs(),
+ "Expected to find {$tag_name} as direct child of BODY as a result of implicitly closing an open P element."
+ );
+ }
+
+ /**
+ * Verifies that tags in the container group, including the ARTICLE element,
+ * nest inside each other despite being invalid in most cases.
+ *
+ * @covers WP_HTML_Processor::step_in_body
+ *
+ * @ticket 59914
+ *
+ * @dataProvider data_article_container_group
+ *
+ * @param string $tag_name Name of tag in group under test.
+ */
+ public function test_in_body_article_group_can_nest_inside_itself( $tag_name ) {
+ $processor = WP_HTML_Processor::create_fragment( "<div><{$tag_name}><{$tag_name}></{$tag_name}><{$tag_name}><span><{$tag_name} target>" );
+
+ while ( $processor->next_tag() && null === $processor->get_attribute( 'target' ) ) {
+ continue;
+ }
+
+ $this->assertSame(
+ array( 'HTML', 'BODY', 'DIV', $tag_name, $tag_name, 'SPAN', $tag_name ),
+ $processor->get_breadcrumbs(),
+ "Expected to find {$tag_name} deeply nested inside itself."
+ );
+ }
+
+ /**
+ * Data provider.
+ *
+ * @return array[].
+ */
+ public function data_article_container_group() {
+ $group = array();
+
+ foreach (
+ array(
+ 'ADDRESS',
+ 'ARTICLE',
+ 'ASIDE',
+ 'BLOCKQUOTE',
+ 'CENTER',
+ 'DETAILS',
+ 'DIALOG',
+ 'DIR',
+ 'DL',
+ 'DIV',
+ 'FIELDSET',
+ 'FIGCAPTION',
+ 'FIGURE',
+ 'FOOTER',
+ 'HEADER',
+ 'HGROUP',
+ 'MAIN',
+ 'MENU',
+ 'NAV',
+ 'SEARCH',
+ 'SECTION',
+ 'SUMMARY',
+ )
+ as $tag_name
+ ) {
+ $group[ $tag_name ] = array( $tag_name );
+ }
+
+ return $group;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Verifies that when encountering an end tag for which there is no corresponding
</span><span class="cx" style="display: block; padding: 0 10px"> * element in scope, that it skips the tag entirely.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -142,11 +241,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * that the HTML processor ignores the end tag if there's a special
</span><span class="cx" style="display: block; padding: 0 10px"> * element on the stack of open elements before the matching opening.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @covers WP_HTML_Processor::step_in_body
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58907
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @covers WP_HTML_Processor::step_in_body
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_any_other_end_tag_with_unclosed_special_element() {
</span><span class="cx" style="display: block; padding: 0 10px"> $p = WP_HTML_Processor::create_fragment( '<div><span><p></span><div>' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -165,11 +264,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * that the HTML processor closes appropriate elements on the stack of
</span><span class="cx" style="display: block; padding: 0 10px"> * open elements up to the matching opening.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @covers WP_HTML_Processor::step_in_body
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58907
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @covers WP_HTML_Processor::step_in_body
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_any_other_end_tag_with_unclosed_non_special_element() {
</span><span class="cx" style="display: block; padding: 0 10px"> $p = WP_HTML_Processor::create_fragment( '<div><span><code></span><div>' );
</span></span></pre>
</div>
</div>
</body>
</html>