[html5] r5638 - [giow] (2) Add in some hard-coded limits for dealing with unclosed formatting el [...]

whatwg at whatwg.org whatwg at whatwg.org
Fri Oct 15 15:56:13 PDT 2010


Author: ianh
Date: 2010-10-15 15:56:11 -0700 (Fri, 15 Oct 2010)
New Revision: 5638

Modified:
   complete.html
   index
   source
Log:
[giow] (2) Add in some hard-coded limits for dealing with unclosed formatting elements to limit the explosive growth of the list of formatting elements in commonly-seen cases.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10802

Modified: complete.html
===================================================================
--- complete.html	2010-10-15 21:52:54 UTC (rev 5637)
+++ complete.html	2010-10-15 22:56:11 UTC (rev 5638)
@@ -1220,7 +1220,8 @@
        <li><a href=#misnested-tags:-b-i-/b-/i><span class=secno>12.2.8.1 </span>Misnested tags: <b><i></b></i></a></li>
        <li><a href=#misnested-tags:-b-p-/b-/p><span class=secno>12.2.8.2 </span>Misnested tags: <b><p></b></p></a></li>
        <li><a href=#unexpected-markup-in-tables><span class=secno>12.2.8.3 </span>Unexpected markup in tables</a></li>
-       <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>12.2.8.4 </span>Scripts that modify the page as it is being parsed</a></ol></ol></li>
+       <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>12.2.8.4 </span>Scripts that modify the page as it is being parsed</a></li>
+       <li><a href=#unclosed-formatting-elements><span class=secno>12.2.8.5 </span>Unclosed formatting elements</a></ol></ol></li>
    <li><a href=#serializing-html-fragments><span class=secno>12.3 </span>Serializing HTML fragments</a></li>
    <li><a href=#parsing-html-fragments><span class=secno>12.4 </span>Parsing HTML fragments</a></li>
    <li><a href=#named-character-references><span class=secno>12.5 </span>Named character references</a></ol></li>
@@ -77398,7 +77399,28 @@
   created, so that further elements can be created for that token if
   necessary.</p>
 
-  <p>When the steps below require the UA to <dfn id=reconstruct-the-active-formatting-elements>reconstruct the
+  <p>When the steps below require the UA to <dfn id=push-onto-the-list-of-active-formatting-elements>push onto the list of
+  active formatting elements</dfn> an element <var title="">element</var>, the UA must perform the following steps:</p>
+
+  <ol><li><p>If there are already three elements in the <a href=#list-of-active-formatting-elements>list of
+   active formatting elements</a> after the last list marker, if
+   any, or anywhere in the list if there are no list markers, that
+   have the same tag name, namespace, and attributes as <var title="">element</var>, then remove the earliest such element from
+   the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>. For these
+   purposes, the attributes must be compared as they were when the
+   elements were created by the parser; two elements have the same
+   attributes if all their parsed attributes can be paired such that
+   the two attributes in each pair have identical names, namespaces,
+   and values (the order of the attributes does not matter).</p>
+
+   <p class=note>This is the Noah's Ark clause. But with three per
+   family instead of two.</li> <!-- A sort of polyamorous Noah's
+   Ark, if you will. -->
+
+   <li><p>Add <var title="">element</var> to the <a href=#list-of-active-formatting-elements>list of active
+   formatting elements</a>.</li>
+
+  </ol><p>When the steps below require the UA to <dfn id=reconstruct-the-active-formatting-elements>reconstruct the
   active formatting elements</dfn>, the UA must perform the following
   steps:</p>
 
@@ -81085,9 +81107,9 @@
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Add that
-    element to the <a href=#list-of-active-formatting-elements>list of active formatting
-    elements</a>.</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push
+    onto the list of active formatting elements</a> that
+    element.</p>
 
    </dd>
 
@@ -81098,9 +81120,9 @@
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Add that
-    element to the <a href=#list-of-active-formatting-elements>list of active formatting
-    elements</a>.</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push
+    onto the list of active formatting elements</a> that
+    element.</p>
 
    </dd>
 
@@ -81117,9 +81139,9 @@
     <a href=#reconstruct-the-active-formatting-elements>reconstruct the active formatting elements</a>, if
     any.</p>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Add that
-    element to the <a href=#list-of-active-formatting-elements>list of active formatting
-    elements</a>.</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push
+    onto the list of active formatting elements</a> that
+    element.</p>
 
    </dd>
 
@@ -81142,16 +81164,20 @@
 
        <li>has the same tag name as the token.</li>
 
-      </ul><p>If there is no such node, or, if that node is also in the
-      <a href=#stack-of-open-elements>stack of open elements</a> but the element is not <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>, then this is a
-      <a href=#parse-error>parse error</a>; ignore the token, and abort these
-      steps.</p>
+      </ul><p>If there is no such node, then abort these steps and instead
+      act as described in the "any other end tag" entry below.</p>
 
       <p>Otherwise, if there is such a node, but that node is not
       in the <a href=#stack-of-open-elements>stack of open elements</a>, then this is a
       <a href=#parse-error>parse error</a>; remove the element from the list,
       and abort these steps.</p>
 
+      <p>Otherwise, if there is such a node, and that node is also in
+      the <a href=#stack-of-open-elements>stack of open elements</a>, but the element is not
+      <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>, then this
+      is a <a href=#parse-error>parse error</a>; ignore the token, and abort these
+      steps.</p>
+
       <p>Otherwise, there is a <var title="">formatting
       element</var> and that element is in <a href=#stack-of-open-elements title="stack of
       open elements">the stack</a> and is <a href=#has-an-element-in-scope title="has an
@@ -83685,8 +83711,38 @@
   <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#script>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "http://example.com/inner".</p>
 
 
+  <h5 id=unclosed-formatting-elements><span class=secno>12.2.8.5 </span>Unclosed formatting elements</h5>
 
+  <p><i>This section is non-normative.</i></p>
 
+  <p>The following markup shows how nested formatting elements (such
+  as <code><a href=#the-b-element>b</a></code>) get collected and continue to be applied even as
+  the elements they are contained in are closed, but that excessive
+  duplicates are thrown away.</p>
+
+  <pre><!DOCTYPE html>
+<p><b class=x><b class=x><b><b class=x><b class=x><b>X
+<p>X
+<p><b><b class=x><b>X
+<p></b></b></b></b></b></b>X</pre>
+
+  <p>The resulting DOM tree is as follows:</p>
+
+  <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element-0>html</a></code><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 t
 itle=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span tit
 le="">X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code
 ><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no
+  explicit <code><a href=#the-b-element>b</a></code> elements, but in the resulting DOM, up to
+  three of each kind of formatting element (in this case three
+  <code><a href=#the-b-element>b</a></code> elements with the class attribute, and two unadorned
+  <code><a href=#the-b-element>b</a></code> elements) get reconstructed before the element's
+  "X".</p>
+
+  <p>Also note how this means that in the final paragraph only six
+  <code><a href=#the-b-element>b</a></code> end tags are needed to completely clear the list of
+  formatting elements, even though nine <code><a href=#the-b-element>b</a></code> start tags have
+  been seen up to this point.</p>
+
+
+
+
   <h3 id=serializing-html-fragments><span class=secno>12.3 </span>Serializing HTML fragments</h3>
 
   <p>The following steps form the <dfn id=html-fragment-serialization-algorithm>HTML fragment serialization

Modified: index
===================================================================
--- index	2010-10-15 21:52:54 UTC (rev 5637)
+++ index	2010-10-15 22:56:11 UTC (rev 5638)
@@ -1143,7 +1143,8 @@
        <li><a href=#misnested-tags:-b-i-/b-/i><span class=secno>10.2.8.1 </span>Misnested tags: <b><i></b></i></a></li>
        <li><a href=#misnested-tags:-b-p-/b-/p><span class=secno>10.2.8.2 </span>Misnested tags: <b><p></b></p></a></li>
        <li><a href=#unexpected-markup-in-tables><span class=secno>10.2.8.3 </span>Unexpected markup in tables</a></li>
-       <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>10.2.8.4 </span>Scripts that modify the page as it is being parsed</a></ol></ol></li>
+       <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>10.2.8.4 </span>Scripts that modify the page as it is being parsed</a></li>
+       <li><a href=#unclosed-formatting-elements><span class=secno>10.2.8.5 </span>Unclosed formatting elements</a></ol></ol></li>
    <li><a href=#serializing-html-fragments><span class=secno>10.3 </span>Serializing HTML fragments</a></li>
    <li><a href=#parsing-html-fragments><span class=secno>10.4 </span>Parsing HTML fragments</a></li>
    <li><a href=#named-character-references><span class=secno>10.5 </span>Named character references</a></ol></li>
@@ -73312,7 +73313,28 @@
   created, so that further elements can be created for that token if
   necessary.</p>
 
-  <p>When the steps below require the UA to <dfn id=reconstruct-the-active-formatting-elements>reconstruct the
+  <p>When the steps below require the UA to <dfn id=push-onto-the-list-of-active-formatting-elements>push onto the list of
+  active formatting elements</dfn> an element <var title="">element</var>, the UA must perform the following steps:</p>
+
+  <ol><li><p>If there are already three elements in the <a href=#list-of-active-formatting-elements>list of
+   active formatting elements</a> after the last list marker, if
+   any, or anywhere in the list if there are no list markers, that
+   have the same tag name, namespace, and attributes as <var title="">element</var>, then remove the earliest such element from
+   the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>. For these
+   purposes, the attributes must be compared as they were when the
+   elements were created by the parser; two elements have the same
+   attributes if all their parsed attributes can be paired such that
+   the two attributes in each pair have identical names, namespaces,
+   and values (the order of the attributes does not matter).</p>
+
+   <p class=note>This is the Noah's Ark clause. But with three per
+   family instead of two.</li> <!-- A sort of polyamorous Noah's
+   Ark, if you will. -->
+
+   <li><p>Add <var title="">element</var> to the <a href=#list-of-active-formatting-elements>list of active
+   formatting elements</a>.</li>
+
+  </ol><p>When the steps below require the UA to <dfn id=reconstruct-the-active-formatting-elements>reconstruct the
   active formatting elements</dfn>, the UA must perform the following
   steps:</p>
 
@@ -76999,9 +77021,9 @@
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Add that
-    element to the <a href=#list-of-active-formatting-elements>list of active formatting
-    elements</a>.</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push
+    onto the list of active formatting elements</a> that
+    element.</p>
 
    </dd>
 
@@ -77012,9 +77034,9 @@
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Add that
-    element to the <a href=#list-of-active-formatting-elements>list of active formatting
-    elements</a>.</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push
+    onto the list of active formatting elements</a> that
+    element.</p>
 
    </dd>
 
@@ -77031,9 +77053,9 @@
     <a href=#reconstruct-the-active-formatting-elements>reconstruct the active formatting elements</a>, if
     any.</p>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Add that
-    element to the <a href=#list-of-active-formatting-elements>list of active formatting
-    elements</a>.</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push
+    onto the list of active formatting elements</a> that
+    element.</p>
 
    </dd>
 
@@ -77056,16 +77078,20 @@
 
        <li>has the same tag name as the token.</li>
 
-      </ul><p>If there is no such node, or, if that node is also in the
-      <a href=#stack-of-open-elements>stack of open elements</a> but the element is not <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>, then this is a
-      <a href=#parse-error>parse error</a>; ignore the token, and abort these
-      steps.</p>
+      </ul><p>If there is no such node, then abort these steps and instead
+      act as described in the "any other end tag" entry below.</p>
 
       <p>Otherwise, if there is such a node, but that node is not
       in the <a href=#stack-of-open-elements>stack of open elements</a>, then this is a
       <a href=#parse-error>parse error</a>; remove the element from the list,
       and abort these steps.</p>
 
+      <p>Otherwise, if there is such a node, and that node is also in
+      the <a href=#stack-of-open-elements>stack of open elements</a>, but the element is not
+      <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>, then this
+      is a <a href=#parse-error>parse error</a>; ignore the token, and abort these
+      steps.</p>
+
       <p>Otherwise, there is a <var title="">formatting
       element</var> and that element is in <a href=#stack-of-open-elements title="stack of
       open elements">the stack</a> and is <a href=#has-an-element-in-scope title="has an
@@ -79599,8 +79625,38 @@
   <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#script>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "http://example.com/inner".</p>
 
 
+  <h5 id=unclosed-formatting-elements><span class=secno>10.2.8.5 </span>Unclosed formatting elements</h5>
 
+  <p><i>This section is non-normative.</i></p>
 
+  <p>The following markup shows how nested formatting elements (such
+  as <code><a href=#the-b-element>b</a></code>) get collected and continue to be applied even as
+  the elements they are contained in are closed, but that excessive
+  duplicates are thrown away.</p>
+
+  <pre><!DOCTYPE html>
+<p><b class=x><b class=x><b><b class=x><b class=x><b>X
+<p>X
+<p><b><b class=x><b>X
+<p></b></b></b></b></b></b>X</pre>
+
+  <p>The resulting DOM tree is as follows:</p>
+
+  <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element-0>html</a></code><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 t
 itle=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span tit
 le="">X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code
 ><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no
+  explicit <code><a href=#the-b-element>b</a></code> elements, but in the resulting DOM, up to
+  three of each kind of formatting element (in this case three
+  <code><a href=#the-b-element>b</a></code> elements with the class attribute, and two unadorned
+  <code><a href=#the-b-element>b</a></code> elements) get reconstructed before the element's
+  "X".</p>
+
+  <p>Also note how this means that in the final paragraph only six
+  <code><a href=#the-b-element>b</a></code> end tags are needed to completely clear the list of
+  formatting elements, even though nine <code><a href=#the-b-element>b</a></code> start tags have
+  been seen up to this point.</p>
+
+
+
+
   <h3 id=serializing-html-fragments><span class=secno>10.3 </span>Serializing HTML fragments</h3>
 
   <p>The following steps form the <dfn id=html-fragment-serialization-algorithm>HTML fragment serialization

Modified: source
===================================================================
--- source	2010-10-15 21:52:54 UTC (rev 5637)
+++ source	2010-10-15 22:56:11 UTC (rev 5638)
@@ -88440,6 +88440,33 @@
   created, so that further elements can be created for that token if
   necessary.</p>
 
+  <p>When the steps below require the UA to <dfn>push onto the list of
+  active formatting elements</dfn> an element <var
+  title="">element</var>, the UA must perform the following steps:</p>
+
+  <ol>
+
+   <li><p>If there are already three elements in the <span>list of
+   active formatting elements</span> after the last list marker, if
+   any, or anywhere in the list if there are no list markers, that
+   have the same tag name, namespace, and attributes as <var
+   title="">element</var>, then remove the earliest such element from
+   the <span>list of active formatting elements</span>. For these
+   purposes, the attributes must be compared as they were when the
+   elements were created by the parser; two elements have the same
+   attributes if all their parsed attributes can be paired such that
+   the two attributes in each pair have identical names, namespaces,
+   and values (the order of the attributes does not matter).</p>
+
+   <p class="note">This is the Noah's Ark clause. But with three per
+   family instead of two.</p></li> <!-- A sort of polyamorous Noah's
+   Ark, if you will. -->
+
+   <li><p>Add <var title="">element</var> to the <span>list of active
+   formatting elements</span>.</p></li>
+
+  </ol>
+
   <p>When the steps below require the UA to <dfn>reconstruct the
   active formatting elements</dfn>, the UA must perform the following
   steps:</p>
@@ -92635,9 +92662,9 @@
     <p><span>Reconstruct the active formatting elements</span>, if
     any.</p>
 
-    <p><span>Insert an HTML element</span> for the token. Add that
-    element to the <span>list of active formatting
-    elements</span>.</p>
+    <p><span>Insert an HTML element</span> for the token. <span>Push
+    onto the list of active formatting elements</span> that
+    element.</p>
 
    </dd>
 
@@ -92648,9 +92675,9 @@
     <p><span>Reconstruct the active formatting elements</span>, if
     any.</p>
 
-    <p><span>Insert an HTML element</span> for the token. Add that
-    element to the <span>list of active formatting
-    elements</span>.</p>
+    <p><span>Insert an HTML element</span> for the token. <span>Push
+    onto the list of active formatting elements</span> that
+    element.</p>
 
    </dd>
 
@@ -92667,9 +92694,9 @@
     <span>reconstruct the active formatting elements</span>, if
     any.</p>
 
-    <p><span>Insert an HTML element</span> for the token. Add that
-    element to the <span>list of active formatting
-    elements</span>.</p>
+    <p><span>Insert an HTML element</span> for the token. <span>Push
+    onto the list of active formatting elements</span> that
+    element.</p>
 
    </dd>
 
@@ -92698,17 +92725,20 @@
 
       </ul>
 
-      <p>If there is no such node, or, if that node is also in the
-      <span>stack of open elements</span> but the element is not <span
-      title="has an element in scope">in scope</span>, then this is a
-      <span>parse error</span>; ignore the token, and abort these
-      steps.</p>
+      <p>If there is no such node, then abort these steps and instead
+      act as described in the "any other end tag" entry below.</p>
 
       <p>Otherwise, if there is such a node, but that node is not
       in the <span>stack of open elements</span>, then this is a
       <span>parse error</span>; remove the element from the list,
       and abort these steps.</p>
 
+      <p>Otherwise, if there is such a node, and that node is also in
+      the <span>stack of open elements</span>, but the element is not
+      <span title="has an element in scope">in scope</span>, then this
+      is a <span>parse error</span>; ignore the token, and abort these
+      steps.</p>
+
       <p>Otherwise, there is a <var title="">formatting
       element</var> and that element is in <span title="stack of
       open elements">the stack</span> and is <span title="has an
@@ -95525,8 +95555,40 @@
   <p>This second alert will say "http://example.com/inner".</p>
 
 
+  <h5>Unclosed formatting elements</h5>
 
+  <p><i>This section is non-normative.</i></p>
 
+  <p>The following markup shows how nested formatting elements (such
+  as <code>b</code>) get collected and continue to be applied even as
+  the elements they are contained in are closed, but that excessive
+  duplicates are thrown away.</p>
+
+  <pre><!DOCTYPE html>
+<p><b class=x><b class=x><b><b class=x><b class=x><b>X
+<p>X
+<p><b><b class=x><b>X
+<p></b></b></b></b></b></b>X</pre>
+
+  <p>The resulting DOM tree is as follows:</p>
+
+  <ul class="domTree"><li class="t10">DOCTYPE: <code>html</code></li><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>p</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">X&#X23CE;</span></li></ul></li></ul></li></ul></li></ul></li></ul>
 </li></ul></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">X&#X23CE;</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="att
 ribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t1"><code>b</code><ul><li class="t1"><code>b</code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">X&#X23CE;</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">X&#X23CE;</span></li></ul></li></ul></li></ul></li></ul>
+
+  <p>Note how the second <code>p</code> element in the markup has no
+  explicit <code>b</code> elements, but in the resulting DOM, up to
+  three of each kind of formatting element (in this case three
+  <code>b</code> elements with the class attribute, and two unadorned
+  <code>b</code> elements) get reconstructed before the element's
+  "X".</p>
+
+  <p>Also note how this means that in the final paragraph only six
+  <code>b</code> end tags are needed to completely clear the list of
+  formatting elements, even though nine <code>b</code> start tags have
+  been seen up to this point.</p>
+
+
+
+
   <h3>Serializing HTML fragments</h3>
 
   <p>The following steps form the <dfn>HTML fragment serialization




More information about the Commit-Watchers mailing list