Skip to content

Commit

Permalink
[giow] (3) Try to simplify the spec by matching the simpler implement…
Browse files Browse the repository at this point in the history
…ations where there is poor interop.

Affected topics: DOM APIs

git-svn-id: http://svn.whatwg.org/webapps@7586 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Dec 14, 2012
1 parent c1b93a4 commit c7b9ee9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 83 deletions.
36 changes: 10 additions & 26 deletions complete.html
Expand Up @@ -248,7 +248,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 13 December 2012</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 14 December 2012</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -8711,10 +8711,8 @@ <h5 id=htmlallcollection-0><span class=secno>2.8.2.1 </span>HTMLAllCollection</h

<p>The <code><a href=#htmlallcollection>HTMLAllCollection</a></code> interface is used for generic <a href=#collections>collections</a> of
elements just like <code><a href=#htmlcollection>HTMLCollection</a></code>, with the exception that its <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method returns an
<code><a href=#htmlallcollection>HTMLAllCollection</a></code> object when there are multiple matching elements, and that its
<code title=dom-HTMLAllCollection-item>item()</code> method can be used as a synonym for its
<code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method. It is intended only for
the legacy <code title=dom-document-all><a href=#dom-document-all>document.all</a></code> attribute.</p>
<code><a href=#htmlcollection>HTMLCollection</a></code> object when there are multiple matching elements, and that its <code title=dom-HTMLAllCollection-item>item()</code> method can be used as a synonym for its <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method. It is intended only for the
legacy <code title=dom-document-all><a href=#dom-document-all>document.all</a></code> attribute.</p>

<pre class=idl>interface <dfn id=htmlallcollection>HTMLAllCollection</dfn> : <a href=#htmlcollection>HTMLCollection</a> {
// inherits <span title=dom-HTMLCollection-length>length</span> and <span title=dom-HTMLCollection-item>item</span>(unsigned long index)
Expand Down Expand Up @@ -8743,7 +8741,7 @@ <h5 id=htmlallcollection-0><span class=secno>2.8.2.1 </span>HTMLAllCollection</h
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
<dd>
<p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or name <var title="">name</var> from the collection.</p>
<p>If there are multiple matching items, then an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object containing all those elements is returned.</p>
<p>If there are multiple matching items, then an <code><a href=#htmlcollection>HTMLCollection</a></code> object containing all those elements is returned.</p>
<p>Only <code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-iframe-element>iframe</a></code>,
<code><a href=#the-img-element>img</a></code>, and <code><a href=#the-object-element>object</a></code> elements can have a name for the purpose of this
Expand All @@ -8765,7 +8763,7 @@ <h5 id=htmlallcollection-0><span class=secno>2.8.2.1 </span>HTMLAllCollection</h

<ol><li>

<p>Let <var title="">collection</var> be an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object rooted at the
<p>Let <var title="">collection</var> be an <code><a href=#htmlcollection>HTMLCollection</a></code> object rooted at the
same node as the <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object on which the method was invoked, whose
filter matches only elements that already match the filter of the <code><a href=#htmlallcollection>HTMLAllCollection</a></code>
object on which the method was invoked and that are either:</p>
Expand Down Expand Up @@ -8933,7 +8931,7 @@ <h5 id=htmloptionscollection-0><span class=secno>2.8.2.3 </span>HTMLOptionsColle
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
<dd>
<p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or <code title=attr-option-name><a href=#attr-option-name>name</a></code> <var title="">name</var> from the collection.</p>
<p>If there are multiple matching items, then a <code><a href=#nodelist>NodeList</a></code> object containing all those elements is returned.</p>
<p>If there are multiple matching items, then the first is returned.</p>
</dd>

<dt><var title="">collection</var> . <code title=dom-HTMLOptionsCollection-add><a href=#dom-htmloptionscollection-add>add</a></code>(<var title="">element</var> [, <var title="">before</var> ] )</dt>
Expand Down Expand Up @@ -8979,25 +8977,11 @@ <h5 id=htmloptionscollection-0><span class=secno>2.8.2.3 </span>HTMLOptionsColle
<p>The <a href=#supported-property-names>supported property names</a> 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><a href=#attr-option-name>name</a></code> attributes of all the
elements <a href=#represented-by-the-collection>represented by the collection</a>.</p>

<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:</p>
<p>The <dfn id=dom-htmloptionscollection-nameditem title=dom-HTMLOptionsCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must return the first 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><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>, if there is one;
otherwise, it must return null.</p>

<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><a href=#attr-option-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-option-name><a href=#attr-option-name>name</a></code> attribute
equal to <var title="">name</var>, then return null and stop the algorithm.</li>

<!-- IE returns an HTMLCollection instead; we may need to change to that for compat -->
<li>Otherwise, create a new <code><a href=#nodelist>NodeList</a></code> object representing a <a href=#live>live</a> view of
the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> object, further filtered so that the only nodes in the
<code><a href=#nodelist>NodeList</a></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><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code><a href=#nodelist>NodeList</a></code> object must be sorted in <a href=#tree-order>tree
order</a>.</li>

<li>Return that <code><a href=#nodelist>NodeList</a></code> object.</li>

</ol><p>When the user agent is to <dfn id=dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>set the value of a new
<p>When the user agent is to <dfn id=dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>set the value of a new
indexed property</dfn> for a given property index <var title="">index</var> to a new value <var title="">value</var>, it must run the following algorithm:</p>

<ol><li><p>If <var title="">value</var> is null, invoke the steps for the <code title=dom-HTMLOptionsCollection-remove><a href=#dom-htmloptionscollection-remove>remove</a></code> method with <var title="">index</var> as
Expand Down
36 changes: 10 additions & 26 deletions index
Expand Up @@ -248,7 +248,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 13 December 2012</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 14 December 2012</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -8711,10 +8711,8 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d

<p>The <code><a href=#htmlallcollection>HTMLAllCollection</a></code> interface is used for generic <a href=#collections>collections</a> of
elements just like <code><a href=#htmlcollection>HTMLCollection</a></code>, with the exception that its <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method returns an
<code><a href=#htmlallcollection>HTMLAllCollection</a></code> object when there are multiple matching elements, and that its
<code title=dom-HTMLAllCollection-item>item()</code> method can be used as a synonym for its
<code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method. It is intended only for
the legacy <code title=dom-document-all><a href=#dom-document-all>document.all</a></code> attribute.</p>
<code><a href=#htmlcollection>HTMLCollection</a></code> object when there are multiple matching elements, and that its <code title=dom-HTMLAllCollection-item>item()</code> method can be used as a synonym for its <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method. It is intended only for the
legacy <code title=dom-document-all><a href=#dom-document-all>document.all</a></code> attribute.</p>

<pre class=idl>interface <dfn id=htmlallcollection>HTMLAllCollection</dfn> : <a href=#htmlcollection>HTMLCollection</a> {
// inherits <span title=dom-HTMLCollection-length>length</span> and <span title=dom-HTMLCollection-item>item</span>(unsigned long index)
Expand Down Expand Up @@ -8743,7 +8741,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
<dd>
<p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or name <var title="">name</var> from the collection.</p>
<p>If there are multiple matching items, then an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object containing all those elements is returned.</p>
<p>If there are multiple matching items, then an <code><a href=#htmlcollection>HTMLCollection</a></code> object containing all those elements is returned.</p>
<p>Only <code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-iframe-element>iframe</a></code>,
<code><a href=#the-img-element>img</a></code>, and <code><a href=#the-object-element>object</a></code> elements can have a name for the purpose of this
Expand All @@ -8765,7 +8763,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d

<ol><li>

<p>Let <var title="">collection</var> be an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object rooted at the
<p>Let <var title="">collection</var> be an <code><a href=#htmlcollection>HTMLCollection</a></code> object rooted at the
same node as the <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object on which the method was invoked, whose
filter matches only elements that already match the filter of the <code><a href=#htmlallcollection>HTMLAllCollection</a></code>
object on which the method was invoked and that are either:</p>
Expand Down Expand Up @@ -8933,7 +8931,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
<dt><var title="">collection</var>(<var title="">name</var>)</dt>
<dd>
<p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or <code title=attr-option-name><a href=#attr-option-name>name</a></code> <var title="">name</var> from the collection.</p>
<p>If there are multiple matching items, then a <code><a href=#nodelist>NodeList</a></code> object containing all those elements is returned.</p>
<p>If there are multiple matching items, then the first is returned.</p>
</dd>

<dt><var title="">collection</var> . <code title=dom-HTMLOptionsCollection-add><a href=#dom-htmloptionscollection-add>add</a></code>(<var title="">element</var> [, <var title="">before</var> ] )</dt>
Expand Down Expand Up @@ -8979,25 +8977,11 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
<p>The <a href=#supported-property-names>supported property names</a> 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><a href=#attr-option-name>name</a></code> attributes of all the
elements <a href=#represented-by-the-collection>represented by the collection</a>.</p>

<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:</p>
<p>The <dfn id=dom-htmloptionscollection-nameditem title=dom-HTMLOptionsCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must return the first 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><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>, if there is one;
otherwise, it must return null.</p>

<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><a href=#attr-option-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-option-name><a href=#attr-option-name>name</a></code> attribute
equal to <var title="">name</var>, then return null and stop the algorithm.</li>

<!-- IE returns an HTMLCollection instead; we may need to change to that for compat -->
<li>Otherwise, create a new <code><a href=#nodelist>NodeList</a></code> object representing a <a href=#live>live</a> view of
the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> object, further filtered so that the only nodes in the
<code><a href=#nodelist>NodeList</a></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><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code><a href=#nodelist>NodeList</a></code> object must be sorted in <a href=#tree-order>tree
order</a>.</li>

<li>Return that <code><a href=#nodelist>NodeList</a></code> object.</li>

</ol><p>When the user agent is to <dfn id=dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>set the value of a new
<p>When the user agent is to <dfn id=dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>set the value of a new
indexed property</dfn> for a given property index <var title="">index</var> to a new value <var title="">value</var>, it must run the following algorithm:</p>

<ol><li><p>If <var title="">value</var> is null, invoke the steps for the <code title=dom-HTMLOptionsCollection-remove><a href=#dom-htmloptionscollection-remove>remove</a></code> method with <var title="">index</var> as
Expand Down

0 comments on commit c7b9ee9

Please sign in to comment.