<?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>15704</bug_id>
          
          <creation_ts>2012-01-25 03:27:16 +0000</creation_ts>
          <short_desc>HTMLFormElement::elements broken for forms outside a document</short_desc>
          <delta_ts>2012-05-07 23:47:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</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>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kent Tamura">tkent</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>adamk</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>mtanalin</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>63092</commentid>
    <comment_count>0</comment_count>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2012-01-25 03:27:16 +0000</bug_when>
    <thetext>http://dev.w3.org/html5/spec/Overview.html#dom-form-elements
&gt; The elements IDL attribute must return an HTMLFormControlsCollection rooted at the Document node, whose filter matches listed elements whose form owner is the form element,  ...

The specification says &quot;rooted at the Document&quot;, so ::elements fo a &lt;form&gt; not in the document tree should be empty. However, IE, Firefox, Opera, and WebKit return non-empty collections for ::elements.

&lt;script&gt;
var f1 = document.createElement(&apos;form&apos;);
f1.appendChild(document.createElement(&apos;input&apos;));
alert(f1.elements.length);
&lt;/script&gt;

This code alerts &apos;1&apos; with major browsers though it should be &apos;0&apos; because &lt;input&gt; is not in the Document tree.

I personally like the current definition of the specification, but it&apos;s not compatible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63096</commentid>
    <comment_count>1</comment_count>
    <who name="Marat Tanalin | tanalin.com">mtanalin</who>
    <bug_when>2012-01-25 11:22:48 +0000</bug_when>
    <thetext>I tend to consider current implementations&apos; behavior more correct. A form contains its elements regardless of whether the form is attached to document.

So probably &quot;rooted at the Document node&quot; part (which is both unreasonable and inconsistent with implementations) should be just removed from the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65524</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-03-14 17:05:18 +0000</bug_when>
    <thetext>We could also say that orphan nodes or nodes in orphan subtrees shouldn&apos;t be associated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65545</commentid>
    <comment_count>3</comment_count>
    <who name="Marat Tanalin | tanalin.com">mtanalin</who>
    <bug_when>2012-03-14 18:16:33 +0000</bug_when>
    <thetext>(In reply to comment #2)
For me, purpose and conclusion of this comment are unclear. Could you be more informative and verbose?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65652</commentid>
    <comment_count>4</comment_count>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2012-03-16 06:24:28 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; We could also say that orphan nodes or nodes in orphan subtrees shouldn&apos;t be
&gt; associated.

Yeah, it would be very simple, and I like it.  But it&apos;s not compatible with existing browsers, and I&apos;m afraid it will break existing web sites.

If we changed the specification to match the existing browsers, the spec would be:

... return an HTMLFormControlCollection rooted at the Document node if the form element is in the document tree, otherwise return an HTMLFormControlCollection rooted at the form element, ...

because we need to handle form controls with &apos;form&apos; content attributes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67436</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-05-07 22:33:21 +0000</bug_when>
    <thetext>looks like we need to reset the form owner of everyone in the form if the form&apos;s ancestor chain changes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67440</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-05-07 23:31:58 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter&apos;s comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67441</commentid>
    <comment_count>7</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-05-07 23:32:17 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7093.
Check-in comment: Try to match implementations better.
http://html5.org/tools/web-apps-tracker?from=7092&amp;to=7093</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67443</commentid>
    <comment_count>8</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-05-07 23:47:52 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7094.
Check-in comment: Try to match implementations better.
http://html5.org/tools/web-apps-tracker?from=7093&amp;to=7094</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>