<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24833</bug_id>
          
          <creation_ts>2014-02-27 01:20:00 +0000</creation_ts>
          <short_desc>AAA step 1 should only pop when current node is not in the list of active formatting elements</short_desc>
          <delta_ts>2014-03-06 19:48:59 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          <blocked>22926</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="William Chen">wchen</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>eseidel</cc>
    
    <cc>hsivonen</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>travil</cc>
    
    <cc>w3c</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>101486</commentid>
    <comment_count>0</comment_count>
    <who name="William Chen">wchen</who>
    <bug_when>2014-02-27 01:20:00 +0000</bug_when>
    <thetext>The fix in Bug 22926 was intended to make properly nested tags behave better but it has a strange side effect on improperly nested tags.

Consider the following example from the html5lib-tests that produces a very different tree before and after the change:

&lt;b id=a&gt; // active formatting elements = [&lt;b id=a&gt;]
&lt;p&gt;
&lt;b id=b&gt; // active formatting elements = [&lt;b id=a&gt;, &lt;b id=b&gt;]
&lt;/p&gt; // *1
&lt;/b&gt; // *2
Text // *3

*1: Pops stack back to &lt;b id=a&gt;, list of formatting elements is unchanged.
*2: Name matches current element, pops &lt;b id=a&gt; off stack, and removes &lt;b id=a&gt; from list of active formatting elements. In the old world, the AAA would remove &lt;b id=b&gt; from the list of active formatting elements and leave the stack untouched.
*3: &quot;reconstruct the active formatting elements&quot; will recreate &lt;b id=b&gt; because it is not on the stack. In the old world, nothing would be reconstructed because &lt;b id=a&gt; is the only item in the list of active formatting elements and it is on the stack.

I propose that step 1 of the AAA should be reworded to something similar to the following (which preserves the old-world behavior of the above example):

If the current node is an HTML element whose tag name is subject, and current node is not in the list of active formatting elements, then run these substeps:
Pop current node off the stack of open elements.
Abort the adoption agency algorithm.

I feel that this handles the Noah&apos;s Arc quirkiness (cause of bug 22926) more precisely, since we only check against the stack with priority in the case where the Noah&apos;s Arc clause removed the node&apos;s entry in the active formatting elements list, otherwise we just let the AAA handle it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101882</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-05 00:16:45 +0000</bug_when>
    <thetext>Looking at the case from bug 22926:

As currently specced:

   &lt;code a&gt;     &lt;!-- A, list is A --&gt;
     &lt;code&gt;     &lt;!-- B, list is A,B --&gt;
      &lt;code&gt;    &lt;!-- C, list is A,B,C --&gt;
       &lt;code&gt;   &lt;!-- D, list is A,B,C,D --&gt;
        &lt;div&gt;
         &lt;code&gt; &lt;!-- E; B gets removed from the list so list is A,C,D,E --&gt;
        &lt;/div&gt;  &lt;!-- pop stack to A,B,C,D; list is still A,C,D,E --&gt;
   &lt;/code&gt;      &lt;!-- closes D; stack is A,B,C; list is A,C,E --&gt;
   &lt;/code&gt;      &lt;!-- closes C; stack is A,B; list is A,E --&gt;
   &lt;/code&gt;      &lt;!-- closes B; stack is A; list is E --&gt;
   &lt;/code&gt;      &lt;!-- closes A; list is E --&gt;
   TEXT         &lt;!-- reopens E, inserts text --&gt;

As proposed by comment 0:

   &lt;code a&gt;     &lt;!-- A, list is A --&gt;
     &lt;code&gt;     &lt;!-- B, list is A,B --&gt;
      &lt;code&gt;    &lt;!-- C, list is A,B,C --&gt;
       &lt;code&gt;   &lt;!-- D, list is A,B,C,D --&gt;
        &lt;div&gt;
         &lt;code&gt; &lt;!-- E; B gets removed from the list so list is A,C,D,E --&gt;
        &lt;/div&gt;  &lt;!-- pop stack to A,B,C,D; list is still A,C,D,E --&gt;
   &lt;/code&gt;      &lt;!-- closes E via AAA.6; stack is A,B,C,D; list is A,C,D --&gt;
   &lt;/code&gt;      &lt;!-- closes D via AAA.10; stack is A,B,C; list is A,C --&gt;
   &lt;/code&gt;      &lt;!-- closes C via AAA.10; stack is A,B; list is A --&gt;
   &lt;/code&gt;      &lt;!-- closes B via new first step; stack is A; list is A --&gt;
   TEXT         &lt;!-- inserts text --&gt;

So the proposal makes sense to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101943</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-05 23:21:37 +0000</bug_when>
    <thetext>Ok, I&apos;m planning on changing the parser as suggested in comment 0. Let me know if you disagree.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102013</commentid>
    <comment_count>3</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-03-06 19:48:48 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8531.
Check-in comment: PARSER CHANGE: Change the Adoption Agency Algorithm so that it only pops the current element if it&apos;s not on the list of formatting elements, since otherwise we can end up with close tags closing things out of order even when they&apos;re all there.
http://html5.org/tools/web-apps-tracker?from=8530&amp;to=8531</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>