<?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>22400</bug_id>
          
          <creation_ts>2013-06-18 21:00:21 +0000</creation_ts>
          <short_desc>[Templates]: Form-associated elements inside templates should not be associated with forms by the parser</short_desc>
          <delta_ts>2013-08-01 20:15:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</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>---</target_milestone>
          
          <blocked>15476</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Klein">adamk</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>dglazkov</cc>
    
    <cc>hsivonen</cc>
    
    <cc>ian</cc>
    
    <cc>rafaelw</cc>
    
    <cc>robin</cc>
    
    <cc>tross</cc>
    
    <cc>w3c</cc>
    
    <cc>wchen</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>89506</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2013-06-18 21:00:21 +0000</bug_when>
    <thetext>For markup such as

(a) &lt;form&gt;&lt;template&gt;&lt;input&gt;&lt;/template&gt;&lt;/form&gt;

or

(b) &lt;template&gt;&lt;form&gt;&lt;template&gt;&lt;input&gt;&lt;/template&gt;&lt;/form&gt;&lt;/template&gt;

the spec currently requires that the &lt;input&gt; be associated with the &lt;form&gt;. But that is incorrect: in case (b), the form and input are in different trees. And in case (a), they are not even in the same document! The existing implementations in WebKit, Blink, and Gecko all make this &quot;mistake&quot;.

To correct it, I propose that the paragraph in the section on &quot;Creating and inserting elements&quot; (http://www.w3.org/html/wg/drafts/html/master/syntax.html#creating-and-inserting-elements) which currently reads:

&quot;If an element created by the insert an HTML element algorithm is a form-associated element, and the form element pointer is not null, and the newly created element doesn&apos;t have a form attribute, the user agent must associate the newly created element with the form element pointed to by the form element pointer when the element is inserted, instead of running the reset the form owner algorithm.&quot;

have an additional clause added, requiring that the element has an ownerDocument with a browsing context. This will keep this special-casing of form association from taking place inside templates. I&apos;ve implemented this in Blink in https://codereview.chromium.org/17033002/ (this misbehavior was causing some crashes, which is why I&apos;m landing the code before a spec update).

An alternate approach would have been to compare the &lt;form&gt;&apos;s ownerDocument with the &lt;input&gt;, but that would lead to the wrong answer in case (b) above (since both &lt;template&gt;&apos;s contents share the same browsing context-less document).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89539</commentid>
    <comment_count>1</comment_count>
    <who name="Rafael Weinstein">rafaelw</who>
    <bug_when>2013-06-19 02:09:30 +0000</bug_when>
    <thetext>+1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90694</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-13 00:17:56 +0000</bug_when>
    <thetext>Note that it doesn&apos;t really much matter, since when the template is stamped out, the associations will be reset anyway, if I&apos;m not mistaken.

Anyway, I agree that it&apos;s unclean as is. I&apos;m happy to update the spec if you want (the suggestion above seems reasonable at first glance). If you want me to take care of it, reassign the bug to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91519</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-08-01 18:18:49 +0000</bug_when>
    <thetext>This test shows that Chrome is not following the spec here, but Firefox is:

   http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2424</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91520</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2013-08-01 18:43:02 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; This test shows that Chrome is not following the spec here, but Firefox is:
&gt; 
&gt;    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2424

What output do you see when you run this in Chrome and Firefox?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91523</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2013-08-01 19:53:41 +0000</bug_when>
    <thetext>To clarify: Chrome is already following the recommendation of this bug, while Firefox is not. Since I&apos;ve heard no objections to changing the spec, assigning to Hixie for him to update it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91525</commentid>
    <comment_count>6</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-08-01 20:15:07 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8115.
Check-in comment: Make &lt;form&gt;&lt;template&gt;&lt;input&gt; not result in the &lt;input&gt; being in the &lt;form&gt;.
http://html5.org/tools/web-apps-tracker?from=8114&amp;to=8115</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>