html5/spec Overview.html,1.1839,1.1840

Update of /sources/public/html5/spec
In directory hutz:/tmp/cvs-serv32681

Modified Files:
	Overview.html 
Log Message:
Redefine how the enumeration works on <form> to be more compatible with content. (whatwg r2670)

Index: Overview.html
===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.1839
retrieving revision 1.1840
diff -u -d -r1.1839 -r1.1840
--- Overview.html	14 Jan 2009 22:05:54 -0000	1.1839
+++ Overview.html	15 Jan 2009 00:58:19 -0000	1.1840
@@ -8,7 +8,7 @@
    <p><a href=http://www.w3.org/><img alt=W3C height=48 src=http://www.w3.org/Icons/w3c_home width=72></a></p>
    <h1>HTML 5</h1>
    <h2 class="no-num no-toc" id=a-vocabulary-and-associated-apis-for-html-and-xhtml>A vocabulary and associated APIs for HTML and XHTML</h2>
-   <h2 class="no-num no-toc" id=editor-s-draft-date-zzz-9-june-2008><!-- "W3C Working Draft" --> Editor's Draft <!--ZZZ-->14 January 2009</h2>
+   <h2 class="no-num no-toc" id=editor-s-draft-date-zzz-9-june-2008><!-- "W3C Working Draft" --> Editor's Draft <!--ZZZ-->15 January 2009</h2>
    <dl><!-- ZZZ: update the month/day
     <dt>This Version:</dt>
     <dd><a href="http://www.w3.org/TR/2009/WD-html5-20090610/">http://www.w3.org/TR/2009/WD-html5-20090610/</a></dd>
@@ -97,7 +97,7 @@
   specification's progress along the W3C Recommendation
   track.
   <!--ZZZ:-->
-  This specification is the 14 January 2009 <!--ZZZ "Working Draft"-->Editor's Draft.
+  This specification is the 15 January 2009 <!--ZZZ "Working Draft"-->Editor's Draft.
   <!--:ZZZ-->
   </p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- relationship to other work (required) --><p>This specification is also being produced by the <a href=http://www.whatwg.org/>WHATWG</a>. The two specifications are
   identical from the table of contents onwards.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- context and rationale (required) --><p>This specification is intended to replace (be a new version of)
@@ -4523,21 +4523,21 @@
   collection</a>.<p>The <dfn id=dom-htmlformcontrolscollection-item title=dom-HTMLFormControlsCollection-item><code>item(<var title="">index</var>)</code></dfn> method must return the <var title="">index</var>th node in the collection. If there is no <var title="">index</var>th node in the collection, then the method must
   return null.<p>The <span>names of the supported named properties</span> consist
   of the values of all the <code title=attr-id><a href=#the-id-attribute>id</a></code> and <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attributes of all the elements
-  <a href=#represented-by-the-collection>represented by the collection</a>.<p>The <dfn id=dom-htmlformcontrolscollection-nameditem title=dom-HTMLFormControlsCollection-namedItem><code>namedItem(<var title="">key</var>)</code></dfn>
-  method must act according to the following algorithm:
+  <a href=#represented-by-the-collection>represented by the collection</a>.<p>The <dfn id=dom-htmlformcontrolscollection-nameditem title=dom-HTMLFormControlsCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must act according to the
+  following algorithm:
 
   <ol><li>If, at the time the method is called, there is exactly one node
-   in the collection that has either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">key</var>, then return that node and stop the
+   in the collection that has either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>, then return that node and stop the
    algorithm.</li>
 
    <li>Otherwise, if there are no nodes in the collection that have
-   either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">key</var>, then return null and stop the algorithm.</li>
+   either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>, then return null and stop the algorithm.</li>
 
    <!-- XXX should we return an HTMLCollection instead, like IE? -->
    <li>Otherwise, create a <code>NodeList</code> object representing a
    live view of the <code><a href=#htmlformcontrolscollection-0>HTMLFormControlsCollection</a></code> object,
    further filtered so that the only nodes in the
-   <code>NodeList</code> object are those that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">key</var>. The nodes in the <code>NodeList</code> object
+   <code>NodeList</code> object are those that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code>NodeList</code> object
    must be sorted in <a href=#tree-order>tree order</a>.</li>
 
    <li>Return that <code>NodeList</code> object.</li>
@@ -4578,15 +4578,15 @@
   remove children from them).<p>The <dfn id=dom-htmloptionscollection-item title=dom-HTMLOptionsCollection-item><code>item(<var title="">index</var>)</code></dfn> method must return the <var title="">index</var>th node in the collection. If there is no <var title="">index</var>th node in the collection, then the method must
   return null.<p>The <span>names of the supported named properties</span> consist
   of the values of all the <code title=attr-id><a href=#the-id-attribute>id</a></code> and <code title=attr-option-name>name</code> attributes of all the elements
-  <a href=#represented-by-the-collection>represented by the collection</a>.<p>The <dfn id=dom-htmloptionscollection-nameditem title=dom-HTMLOptionsCollection-namedItem><code>namedItem(<var title="">key</var>)</code></dfn>
-  method must act according to the following algorithm:
+  <a href=#represented-by-the-collection>represented by the collection</a>.<p>The <dfn id=dom-htmloptionscollection-nameditem title=dom-HTMLOptionsCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must act according to the
+  following algorithm:
 
   <ol><li>If, at the time the method is called, there is exactly one node
-   in the collection that has either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name>name</code> attribute equal to <var title="">key</var>, then return that node and stop the
+   in the collection that has either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name>name</code> attribute equal to <var title="">name</var>, then return that node and stop the
    algorithm.</li>
 
    <li>Otherwise, if there are no nodes in the collection that have
-   either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name>name</code> attribute equal to <var title="">key</var>, then return null and stop the algorithm.</li>
+   either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name>name</code> attribute equal to <var title="">name</var>, then return null and stop the algorithm.</li>
 
    <!-- XXX should we return an HTMLCollection instead, like IE? -->
    <li>Otherwise, create a <code>NodeList</code> object representing a
@@ -4594,7 +4594,7 @@
    filtered so that the only nodes in the <code>NodeList</code> object
    are those that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code>
    attribute or a <code title=attr-option-name>name</code> attribute
-   equal to <var title="">key</var>. The nodes in the
+   equal to <var title="">name</var>. The nodes in the
    <code>NodeList</code> object must be sorted in <a href=#tree-order>tree
    order</a>.</li>
 
@@ -19425,21 +19425,69 @@
   owner</a> is the <code><a href=#the-form-element>form</a></code> element, with the exception of
   <code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, which must,
   for historical reasons, be excluded from this particular
-  collection.<p>The <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection is
-  also mirrored on the <code><a href=#htmlformelement>HTMLFormElement</a></code> object. The <dfn id=dom-form-length title=dom-form-length><code>length</code></dfn> DOM attribute must
-  return the number of nodes <a href=#represented-by-the-collection title="represented by the
-  collection">represented</a> by the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection. The
+  collection.</p><hr><p>The <dfn id=dom-form-length title=dom-form-length><code>length</code></dfn> DOM
+  attribute must return the number of nodes <a href=#represented-by-the-collection title="represented
+  by the collection">represented</a> by the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection.<p>The
   <span>indices of the supported indexed properties</span> at any
   instant are the indicies supported by the object returned by the
   <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> attribute at that
-  instant. The <span>names
-  of the supported named properties</span> at any instant are the
-  names supported by the object returned by the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> attribute at that
   instant.<p>The <dfn id=dom-form-item title=dom-form-item><code>item(<var title="">index</var>)</code></dfn> method must return the value
   returned by the method of the same name on the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection, when invoked
-  with the same argument.<p>The <dfn id=dom-form-nameditem title=dom-form-namedItem><code>namedItem(<var title="">index</var>)</code></dfn> method must return the value
-  returned by the method of the same name on the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection, when invoked
-  with the same argument.<p>The <dfn id=dom-form-submit title=dom-form-submit><code>submit()</code></dfn>
+  with the same argument.<p>Each <code><a href=#the-form-element>form</a></code> element has a mapping of names to elements
+  called the <dfn id=past-names-map>past names map</dfn>. It is used to persist names of
+  controls even when they change names.<p>The <span>names of the supported named properties</span> are the
+  union of the names currently supported by the object returned by the
+  <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> attribute, and the
+  names currently in the <a href=#past-names-map>past names map</a>.<p>The <dfn id=dom-form-nameditem title=dom-form-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method, when called, must run the
+  following steps:<ol><li>
+
+    <p>If <var title="">name</var> is one of the <span>names of the
+    supported named properties</span> of the object returned by the
+    <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> attribute, then
+    run these substeps:</p>
+
+    <ol><li><p>Let <var title="">candidate</var> be the object returned
+     by the <code title=dom-HTMLFormControlsCollection-namedItem><a href=#dom-htmlformcontrolscollection-nameditem>namedItem()</a></code>
+     method on the object returned by the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> attribute when passed
+     the <var title="">name</var> argument.</li>
+
+     <li><p>If <var title="">candidate</var> is an element, then add a
+     mapping from <var title="">name</var> to <var title="">candidate</var> in the <code><a href=#the-form-element>form</a></code> element's
+     <a href=#past-names-map>past names map</a>, replacing the previous entry with
+     the same name, if any.</li>
+
+     <li><p>Return <var title="">candidate</var> and abort these
+     steps.</li>
+
+    </ol></li>
+
+   <li><p>Otherwise, <var title="">name</var> is the name of one of
+   the entries in the <code><a href=#the-form-element>form</a></code> element's <a href=#past-names-map>past names
+   map</a>: return the object associated with <var title="">name</var> in that map.</li>
+
+  </ol><p>If an element listed in the <code><a href=#the-form-element>form</a></code> element's <a href=#past-names-map>past
+  names map</a> is removed from the <code>Document</code>, then its
+  entries must be removed from the map.</p><!--
+    This ridiculous setup is intended to do as much of the right thing
+    while still supporting code written to work in IE7. IE versions
+    prior to IE8 do not update the names on the <form> element
+    collection to match new names when elements are renamed, and there
+    are enough pages that rename elements and then access them by
+    their old name that we have to support this.
+
+    But we still want to expose them using the new names, so as far as
+    possible we pretend the legacy names aren't there except if
+    there's no other element actually named that way.
+
+    Removing the element did remove the legacy name in IE7:
+    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Cform%20action%3D%22%2F%22%3E%3Cinput%20name%3Dsubmit%3E%3C%2Fform%3E%0A%3Cscript%3E%0A%20w(document.forms%5B0%5D.submit)%3B%0A%20w(document.forms%5B0%5D.removeChild(document.getElementsByTagName('input')%5B0%5D))%3B%0A%20w(document.forms%5B0%5D.length)%3B%0A%20try%20%7B%20document.forms%5B0%5D.submit()%3B%20%7D%20catch%20(e)%20%20%7B%20w(e.message)%20%7D%0A%3C%2Fscript%3E
+
+    There's no interop on what happens when the name was originally a
+    duplicate name, so we don't persist such accesses - at the time
+    of writing, Safari returned the first element, Firefox returned
+    null (as we do), and IE7 returned the original collection:
+    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Cform%20action%3D%22%2F%22%3E%3Cinput%20name%3Da%20id%3Dfirst%3E%3Cinput%20name%3Da%20id%3Dsecond%3E%3C%2Fform%3E%0A%3Cscript%3E%0A%20w%28document.forms[0].a%29%3B%0A%20document.getElementsByTagName%28%27input%27%29[0].name%20%3D%20%27b%27%3B%0A%20document.getElementsByTagName%28%27input%27%29[1].name%20%3D%20%27b%27%3B%0A%20w%28document.forms[0].length%29%3B%0A%20w%28document.forms[0].a.id%29%3B%0A%3C%2Fscript%3E
+  --><hr><p>The <dfn id=dom-form-submit title=dom-form-submit><code>submit()</code></dfn>
   method, when invoked, must <a href=#concept-form-submit title=concept-form-submit>submit</a> the <code><a href=#the-form-element>form</a></code>
   element from the <code><a href=#the-form-element>form</a></code> element itself.<p>The <dfn id=dom-form-reset title=dom-form-reset><code>reset()</code></dfn>
   method, when invoked, must <a href=#concept-form-reset title=concept-form-reset>reset</a> the <code><a href=#the-form-element>form</a></code>
@@ -23034,7 +23082,7 @@
   <code title=dom-select-options><a href=#dom-select-options>options</a></code> attribute at that
   instant.<p>The <dfn id=dom-select-item title=dom-select-item><code>item(<var title="">index</var>)</code></dfn> method must return the value
   returned by the method of the same name on the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection, when invoked
-  with the same argument.<p>The <dfn id=dom-select-nameditem title=dom-select-namedItem><code>namedItem(<var title="">index</var>)</code></dfn> method must return the value
+  with the same argument.<p>The <dfn id=dom-select-nameditem title=dom-select-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must return the value
   returned by the method of the same name on the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection, when invoked
   with the same argument.<p>Similarly, the <dfn id=dom-select-add title=dom-select-add><code>add()</code></dfn> and <dfn id=dom-select-remove title=dom-select-remove><code>remove()</code></dfn> methods must
   act like their namesake methods on that same <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection.<p>The <dfn id=dom-select-selectedoptions title=dom-select-selectedOptions><code>selectedOptions</code></dfn>

Received on Thursday, 15 January 2009 00:58:41 UTC