<?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>27314</bug_id>
          
          <creation_ts>2014-11-12 13:31:14 +0000</creation_ts>
          <short_desc>Parser: &quot;adjusted current node&quot; not clear enough</short_desc>
          <delta_ts>2019-03-29 19:43:08 +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>Other</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc>https://html.spec.whatwg.org/#adjusted-current-node</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>d</cc>
    
    <cc>hsivonen</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>n.oxyde</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>114837</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-11-12 13:31:14 +0000</bug_when>
    <thetext>Specification: https://html.spec.whatwg.org/multipage/syntax.html
Multipage: https://html.spec.whatwg.org/multipage/#adjusted-current-node
Complete: https://html.spec.whatwg.org/#adjusted-current-node
Referrer: https://html.spec.whatwg.org/multipage/

Comment:
&quot;adjusted current node&quot; not clear enough.
&lt;http://www.w3.org/mid/546285C8.1050701@mit.edu&gt;

Posted from: 94.234.170.93 by simonp@opera.com
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.52 Safari/537.36 OPR/26.0.1656.17 (Edition beta)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114858</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-12 19:14:23 +0000</bug_when>
    <thetext>How would you like this editorial issue addressed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114892</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-13 16:39:19 +0000</bug_when>
    <thetext>I think it would make more sense to me we introduce a concept like &quot;override current node&quot; (name tbd) and define adjusted current node like so:

  The adjusted current node is override current node if the stack of open
  elements has only one element in it and the override current node is set;
  otherwise, the adjusted current node is the current node

And then the fragment parsing algorithm would set the override current node.  This would encapsulate all the information needed to determine the current node in the parser bits, with a concrete API entry point the fragment parsing algorithm uses.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114906</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-13 23:52:14 +0000</bug_when>
    <thetext>I don&apos;t understand how this differs from what we have now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114909</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-14 00:03:54 +0000</bug_when>
    <thetext>It differs by not referring to non-local &quot;context object&quot; state from some other algorithm.  Instead, all the state the parser needs is right on the parser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115144</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-19 21:59:12 +0000</bug_when>
    <thetext>How is &quot;override current node&quot; any more local than &quot;context object&quot;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115152</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-19 22:15:45 +0000</bug_when>
    <thetext>The former is a property of the parser, but the latter is a property of some algorithm that later calls into the parser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115153</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-19 22:16:29 +0000</bug_when>
    <thetext>I mean, if you have better ideas, that would be good too.  I just have a data point: at least 3 people including myself read this spec bit and were totally confused about the behavior.  I _think_ with my phrasing they would not have been confused.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115177</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-20 00:24:59 +0000</bug_when>
    <thetext>I guess I don&apos;t understand why &quot;context element&quot; is not a property of the parser. It&apos;s even hyperlinked to its definition right there at the top of the &quot;HTML fragment parsing algorithm&quot;. If we introduce yet another term, which itself would just be defined in terms of the &quot;context element&quot;, that just seems like a net increase in complexity. I mean, your definition is isomorphic with the current one, except with one layer of indirection added, no?

I guess I don&apos;t understand what&apos;s confusing about the current text. The link in comment 0 doesn&apos;t really explain what the problem is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115185</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-20 02:14:28 +0000</bug_when>
    <thetext>I don&apos;t know why people can&apos;t get that out of the spec text until it&apos;s explicitly pointed out to them.  We just have empirical evidence they can&apos;t.

I should also note that afaict the behavior is underdefined right now when there is no context element, unless I&apos;m missing something...  my proposed phrasing would in fact fix that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115246</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-20 17:59:58 +0000</bug_when>
    <thetext>My problem is that if I don&apos;t know why people don&apos;t understand the spec, I can&apos;t fix it. I have no way to evaluate whether your proposed fix would improve clarity. My judgement is that it would be net worse since it has more indirection. I could be wrong. I don&apos;t know. That&apos;s the point.

Looks like the context node being optional is no longer needed, so I&apos;ve dropped all that. I&apos;ve also reordered some sentences and added some notes to make some things hopefully a little clearer. But again, without understanding the source of the confusion, I can&apos;t really fix this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115247</commentid>
    <comment_count>11</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-11-20 18:08:39 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8856.
Check-in comment: Try to clarify stuff around fragment parsing (this removes the ability to call the fragment parsing algorithm without a context node; I couldn&apos;t find anyone doing that, but if I missed a case please let me know)
https://html5.org/tools/web-apps-tracker?from=8855&amp;to=8856</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115250</commentid>
    <comment_count>12</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-20 18:39:23 +0000</bug_when>
    <thetext>I think from my point of view there is less indirection in my proposal.  The parser just directly uses the state of the parser instead of using the ambient state of being of some other algorithm that invoked the parser...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115317</commentid>
    <comment_count>13</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-21 22:03:40 +0000</bug_when>
    <thetext>The HTML fragment parsing algorithm is part of the parser. (Technically it&apos;s actually the only defined entry-point into the parser... the other uses of the parser are much more handwavy.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115344</commentid>
    <comment_count>14</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-22 02:18:01 +0000</bug_when>
    <thetext>Maybe I should have been more precise.  The relevant state is consumed by the tree builder, or whatever it is that creates actual element instances.  That&apos;s where it should be stored, imo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115414</commentid>
    <comment_count>15</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-24 18:46:10 +0000</bug_when>
    <thetext>Oh it&apos;s definitely a mistake to consider the tree building a separate component from the rest of the parser. The tree constructor is intricately intertwined with lost of other parts of the platform, including e.g. the tokeniser, the initial parser setup, and so on. I really don&apos;t think that adding a new term just in the tree construction section, which is merely defined as being something outside the tree construction section, would help simplify anything.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115422</commentid>
    <comment_count>16</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-24 19:20:38 +0000</bug_when>
    <thetext>&gt; Oh it&apos;s definitely a mistake to consider the tree building a separate component
&gt; from the rest of the parser.

In actual implementations, the tree building and tokenization don&apos;t even run on the same thread.  So they&apos;re somewhat separate.  Tightly coupled, to be sure, but separate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115438</commentid>
    <comment_count>17</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-25 07:13:20 +0000</bug_when>
    <thetext>I disagree that running on a second thread implies any sort of design or conceptual separation. But now we&apos;re getting to rather philosophical points.

How&apos;s the current text in the spec? Do you still find it confusing? Can you elaborate on why you find it confusing, if so? What interpretations of the current spec do you initially have?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115467</commentid>
    <comment_count>18</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-25 13:58:48 +0000</bug_when>
    <thetext>It&apos;s really hard to evaluate that now that I know what the answer is.

I suggest finding people who haven&apos;t looked at this spec before and asking them a concrete question, like so:

Given this markup:

   &lt;svg&gt;&lt;g&gt;&lt;/g&gt;&lt;/svg&gt;

and this script:

   document.querySelector(&quot;g&quot;).innerHTML = &quot;&lt;a&gt;&lt;/a&gt;&quot;;

what is the namespace of the resulting &lt;a&gt; element?  This is the question that I saw multiple people answer incorrectly due to the way this spec section is written...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115468</commentid>
    <comment_count>19</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-25 14:00:07 +0000</bug_when>
    <thetext>&gt; what is the namespace of the resulting &lt;a&gt; element? 

&quot;And why?&quot; of course.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115553</commentid>
    <comment_count>20</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-26 19:59:55 +0000</bug_when>
    <thetext>In bug 26783 comment 8 Henri suggests that we just go through and change all the uses of &quot;html&quot; as a sentinel node to just check the size of the stack, so then we can just put the context node on the stack and solve this entire problem with much less prose.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115620</commentid>
    <comment_count>21</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-11-27 14:06:25 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #20)
&gt; In bug 26783 comment 8 Henri suggests that we just go through and change all
&gt; the uses of &quot;html&quot; as a sentinel node to just check the size of the stack,
&gt; so then we can just put the context node on the stack and solve this entire
&gt; problem with much less prose.

I approve of making the spec match the Validator.nu/Gecko code more closely, since I think the result would be conceptually clearer. ;-)

(In reply to Boris Zbarsky from comment #7)
&gt; I mean, if you have better ideas, that would be good too.  I just have a
&gt; data point: at least 3 people including myself read this spec bit and were
&gt; totally confused about the behavior.  I _think_ with my phrasing they would
&gt; not have been confused.

In the Servo context? Or has there been a need to others than me (and wchen while reviewing) to look at this in the Gecko context?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115623</commentid>
    <comment_count>22</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-27 14:38:55 +0000</bug_when>
    <thetext>This was in Gecko, when triaging bug reports about innerHTML inside SVG stuff.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123056</commentid>
    <comment_count>23</comment_count>
    <who name="Anthony Ramine">n.oxyde</who>
    <bug_when>2015-09-03 08:45:27 +0000</bug_when>
    <thetext>This vagueness also make parsing template fragments wrong. https://html.spec.whatwg.org/multipage/syntax.html#appropriate-place-for-inserting-a-node ends up returning the only element in the stack of opened elements.

See web-platform-test:
/html/semantics/scripting-1/the-template-element/definitions/template-contents.html
&quot;The template contents must be a DocumentFragment (nested template containing a text node)&quot;

According to spec, #t2 should be appended to the outer template itself, and not its template contents. That sounds like a bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123069</commentid>
    <comment_count>24</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-09-04 07:38:52 +0000</bug_when>
    <thetext>I filed https://github.com/w3c/DOM-Parsing/issues/1 on the &lt;template&gt; issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129664</commentid>
    <comment_count>25</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2019-03-29 19:43:08 +0000</bug_when>
    <thetext>https://github.com/whatwg/html/issues/4467</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>