Skip to content

Commit

Permalink
Fix #104: the name attribute can only appear on HTML elements
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Nov 11, 2015
1 parent 55169f6 commit eda3dcd
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 83 deletions.
85 changes: 38 additions & 47 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2298,9 +2298,7 @@ interface HTMLCollection {
};
</pre>

An {{HTMLCollection}} object is a
<a>collection</a> of
<a for="/">elements</a>.
<p>An {{HTMLCollection}} object is a <a>collection</a> of <a for="/">elements</a>.

<p class="note no-backref">{{Elements}} is the better solution for representing a
<a>collection</a> of <a for="/">elements</a>. {{HTMLCollection}} is an historical artifact we
Expand All @@ -2326,69 +2324,62 @@ cannot rid the web of.
from the collection.
</dl>

<div class=impl>

The object's <a>supported property indices</a>
are the numbers in the range zero to one less than the number of nodes
<a>represented by the collection</a>. If there are no such elements, then
<p>The object's <a>supported property indices</a> are the numbers in the range zero to one less than
the number of elements <a>represented by the collection</a>. If there are no such elements, then
there are no <a>supported property indices</a>.

The <dfn attribute for=HTMLCollection>length</dfn> attribute
must return the number of nodes <a>represented by the collection</a>.
<p>The <dfn attribute for=HTMLCollection><code>length</code></dfn> attribute's getter must return
the number of nodes <a>represented by the collection</a>.

The
<dfn method for=HTMLCollection>item(<var>index</var>)</dfn>
method must return the <var>index</var><sup>th</sup>
<a for="/">element</a> in the <a>collection</a>. If there is no
<var>index</var><sup>th</sup> <a for="/">element</a> in the <a>collection</a>, then the method must return null.
<p>The <dfn method for=HTMLCollection><code>item(<var>index</var>)</code></dfn> method, when
invoked, must return the <var>index</var><sup>th</sup> <a for="/">element</a> in the
<a>collection</a>. If there is no <var>index</var><sup>th</sup> <a for="/">element</a> in the
<a>collection</a>, then the method must return null.

The <a>supported property names</a>, all <a>unenumerable</a>,
are the values from the list returned by these steps:
<p>The <a>supported property names</a>, all <a>unenumerable</a>, are the values from the list
returned by these steps:

<ol>
<li>Let <var>result</var> be an empty list.
<li><p>Let <var>result</var> be an empty list.

<li>
For each <var>element</var>
<a>represented by the collection</a>, in
<a>tree order</a>, run these substeps:
<p>For each <var>element</var> <a>represented by the collection</a>, in <a>tree order</a>, run
these substeps:

<ol>
<li>If <var>element</var> has an
<a>ID</a> which is neither the empty string nor is
in <var>result</var>, append <var>element</var>'s
<a>ID</a> to <var>result</var>.

<li>If <var>element</var> is in the <a>HTML namespace</a>
and <a lt="has an attribute">has</a> a
<a lt="named attribute"><code>name</code> attribute</a>
whose <a for=Attr>value</a> is neither the
empty string nor is in <var>result</var>, append
<var>element</var>'s
<a lt="named attribute"><code>name</code> attribute</a>
<a for=Attr>value</a> to <var>result</var>.
<li><p>If <var>element</var> has an <a>ID</a> which is not in <var>result</var>, append
<var>element</var>'s <a>ID</a> to <var>result</var>.

<li><p>If <var>element</var> is in the <a>HTML namespace</a> and <a lt="has an attribute">has</a>
a <a lt="named attribute"><code>name</code> attribute</a> whose <a for=Attr>value</a> is neither
the empty string nor is in <var>result</var>, append <var>element</var>'s
<a lt="named attribute"><code>name</code> attribute</a> <a for=Attr>value</a> to
<var>result</var>.
</ol>
<li>Return <var>result</var>.

<li><p>Return <var>result</var>.
</ol>

The
<dfn method for=HTMLCollection>namedItem(<var>key</var>)</dfn>
method must run these steps:
<p>The <dfn method for=HTMLCollection><code>namedItem(<var>key</var>)</code></dfn> method, when
invoked, must run these steps:

<ol>
<li>If <var>key</var> is the empty string, return null.
<li><p>If <var>key</var> is the empty string, return null.

<li>
Return the first <a for="/">element</a> in the
<a>collection</a> for which at least one of
<p>Return the first <a for="/">element</a> in the <a>collection</a> for which at least one of
the following is true:

<ul>
<li>it has an <a>ID</a> which is <var>key</var>;
<li>it <a lt="has an attribute">has</a> a
<a lt="named attribute"><code>name</code> attribute</a>
whose <a for=Attr>value</a> is

<li>it is in the <a>HTML namespace</a> and <a lt="has an attribute">has</a> a
<a lt="named attribute"><code>name</code> attribute</a> whose <a for=Attr>value</a> is
<var>key</var>;
</ul>
or null if there is no such <a for="/">element</a>.
</ol>

</div>
<p>or null if there is no such <a for="/">element</a>.
</ol>



Expand Down
78 changes: 42 additions & 36 deletions dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<div class="head">
<p data-fill-with="logo"><a class="logo" href="https://whatwg.org/"> <img alt="WHATWG" height="100" src="https://resources.whatwg.org/logo-dom.svg"> </a> </p>
<h1 class="p-name no-ref allcaps" id="title">DOM</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Living Standard — Last Updated <time class="dt-updated" datetime="2015-11-10">10 November 2015</time></span></h2>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Living Standard — Last Updated <time class="dt-updated" datetime="2015-11-11">11 November 2015</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>Participate:
Expand Down Expand Up @@ -1296,7 +1296,7 @@ <h5 class="heading settled" data-level="4.2.7.2" id="interface-htmlcollection"><
getter <a data-link-type="idl-name" href="#element">Element</a>? <a class="idl-code" data-link-type="method" href="#dom-htmlcollection-nameditem">namedItem</a>(DOMString <dfn class="idl-code" data-dfn-for="HTMLCollection/namedItem(name)" data-dfn-type="argument" data-export="" id="dom-htmlcollection-nameditem-name-name">name<a class="self-link" href="#dom-htmlcollection-nameditem-name-name"></a></dfn>);
};
</pre>
<p>An <code class="idl"><a data-link-type="idl" href="#htmlcollection">HTMLCollection</a></code> object is a <a data-link-type="dfn" href="#concept-collection">collection</a> of <a data-link-type="dfn" href="#concept-element">elements</a>.</p>
<p>An <code class="idl"><a data-link-type="idl" href="#htmlcollection">HTMLCollection</a></code> object is a <a data-link-type="dfn" href="#concept-collection">collection</a> of <a data-link-type="dfn" href="#concept-element">elements</a>. </p>
<p class="note no-backref" role="note"><code class="idl"><a data-link-type="idl" href="#elements">Elements</a></code> is the better solution for representing a <a data-link-type="dfn" href="#concept-collection">collection</a> of <a data-link-type="dfn" href="#concept-element">elements</a>. <code class="idl"><a data-link-type="idl" href="#htmlcollection">HTMLCollection</a></code> is an historical artifact we
cannot rid the web of. </p>
<dl class="domintro">
Expand All @@ -1311,39 +1311,45 @@ <h5 class="heading settled" data-level="4.2.7.2" id="interface-htmlcollection"><
<dt><var>element</var> = <var>collection</var>[<var>name</var>]
<dd> Returns the first <a data-link-type="dfn" href="#concept-element">element</a> with <a data-link-type="dfn" href="#concept-id">ID</a> or name <var>name</var> from the collection.
</dl>
<div class="impl">
<p>The object’s <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-indices">supported property indices</a> are the numbers in the range zero to one less than the number of nodes <a data-link-type="dfn" href="#represented-by-the-collection">represented by the collection</a>. If there are no such elements, then
there are no <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-indices">supported property indices</a>.</p>
<p>The <dfn class="idl-code" data-dfn-for="HTMLCollection" data-dfn-type="attribute" data-export="" id="dom-htmlcollection-length">length<a class="self-link" href="#dom-htmlcollection-length"></a></dfn> attribute
must return the number of nodes <a data-link-type="dfn" href="#represented-by-the-collection">represented by the collection</a>.</p>
<p>The <dfn class="idl-code" data-dfn-for="HTMLCollection" data-dfn-type="method" data-export="" id="dom-htmlcollection-item">item(<var>index</var>)<a class="self-link" href="#dom-htmlcollection-item"></a></dfn> method must return the <var>index</var><sup>th</sup> <a data-link-type="dfn" href="#concept-element">element</a> in the <a data-link-type="dfn" href="#concept-collection">collection</a>. If there is no <var>index</var><sup>th</sup> <a data-link-type="dfn" href="#concept-element">element</a> in the <a data-link-type="dfn" href="#concept-collection">collection</a>, then the method must return null.</p>
<p>The <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-names">supported property names</a>, all <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-unenumerable">unenumerable</a>,
are the values from the list returned by these steps:</p>
<ol>
<li>Let <var>result</var> be an empty list.
<li>
For each <var>element</var> <a data-link-type="dfn" href="#represented-by-the-collection">represented by the collection</a>, in <a data-link-type="dfn" href="#concept-tree-order">tree order</a>, run these substeps:
<ol>
<li>If <var>element</var> has an <a data-link-type="dfn" href="#concept-id">ID</a> which is neither the empty string nor is
in <var>result</var>, append <var>element</var>’s <a data-link-type="dfn" href="#concept-id">ID</a> to <var>result</var>.
<li>If <var>element</var> is in the <a data-link-type="dfn" href="#html-namespace">HTML namespace</a> and <a data-link-type="dfn" href="#concept-element-attribute-has">has</a> a <a data-link-type="dfn" href="#concept-named-attribute"><code>name</code> attribute</a> whose <a data-link-type="dfn" href="#concept-attribute-value">value</a> is neither the
empty string nor is in <var>result</var>, append <var>element</var>’s <a data-link-type="dfn" href="#concept-named-attribute"><code>name</code> attribute</a> <a data-link-type="dfn" href="#concept-attribute-value">value</a> to <var>result</var>.
</ol>
<li>Return <var>result</var>.
</ol>
<p>The <dfn class="idl-code" data-dfn-for="HTMLCollection" data-dfn-type="method" data-export="" data-lt="namedItem(name)" id="dom-htmlcollection-nameditem">namedItem(<var>key</var>)<a class="self-link" href="#dom-htmlcollection-nameditem"></a></dfn> method must run these steps:</p>
<ol>
<li>If <var>key</var> is the empty string, return null.
<li>
Return the first <a data-link-type="dfn" href="#concept-element">element</a> in the <a data-link-type="dfn" href="#concept-collection">collection</a> for which at least one of
the following is true:
<ul>
<li>it has an <a data-link-type="dfn" href="#concept-id">ID</a> which is <var>key</var>;
<li>it <a data-link-type="dfn" href="#concept-element-attribute-has">has</a> a <a data-link-type="dfn" href="#concept-named-attribute"><code>name</code> attribute</a> whose <a data-link-type="dfn" href="#concept-attribute-value">value</a> is <var>key</var>;
</ul>
or null if there is no such <a data-link-type="dfn" href="#concept-element">element</a>.
</ol>
</div>
<p>The object’s <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-indices">supported property indices</a> are the numbers in the range zero to one less than
the number of elements <a data-link-type="dfn" href="#represented-by-the-collection">represented by the collection</a>. If there are no such elements, then
there are no <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-indices">supported property indices</a>. </p>
<p>The <dfn class="idl-code" data-dfn-for="HTMLCollection" data-dfn-type="attribute" data-export="" id="dom-htmlcollection-length"><code>length</code><a class="self-link" href="#dom-htmlcollection-length"></a></dfn> attribute’s getter must return
the number of nodes <a data-link-type="dfn" href="#represented-by-the-collection">represented by the collection</a>. </p>
<p>The <dfn class="idl-code" data-dfn-for="HTMLCollection" data-dfn-type="method" data-export="" id="dom-htmlcollection-item"><code>item(<var>index</var>)</code><a class="self-link" href="#dom-htmlcollection-item"></a></dfn> method, when
invoked, must return the <var>index</var><sup>th</sup> <a data-link-type="dfn" href="#concept-element">element</a> in the <a data-link-type="dfn" href="#concept-collection">collection</a>. If there is no <var>index</var><sup>th</sup> <a data-link-type="dfn" href="#concept-element">element</a> in the <a data-link-type="dfn" href="#concept-collection">collection</a>, then the method must return null. </p>
<p>The <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-names">supported property names</a>, all <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-unenumerable">unenumerable</a>, are the values from the list
returned by these steps: </p>
<ol>
<li>
<p>Let <var>result</var> be an empty list. </p>
<li>
<p>For each <var>element</var> <a data-link-type="dfn" href="#represented-by-the-collection">represented by the collection</a>, in <a data-link-type="dfn" href="#concept-tree-order">tree order</a>, run
these substeps: </p>
<ol>
<li>
<p>If <var>element</var> has an <a data-link-type="dfn" href="#concept-id">ID</a> which is not in <var>result</var>, append <var>element</var>’s <a data-link-type="dfn" href="#concept-id">ID</a> to <var>result</var>. </p>
<li>
<p>If <var>element</var> is in the <a data-link-type="dfn" href="#html-namespace">HTML namespace</a> and <a data-link-type="dfn" href="#concept-element-attribute-has">has</a> a <a data-link-type="dfn" href="#concept-named-attribute"><code>name</code> attribute</a> whose <a data-link-type="dfn" href="#concept-attribute-value">value</a> is neither
the empty string nor is in <var>result</var>, append <var>element</var>’s <a data-link-type="dfn" href="#concept-named-attribute"><code>name</code> attribute</a> <a data-link-type="dfn" href="#concept-attribute-value">value</a> to <var>result</var>. </p>
</ol>
<li>
<p>Return <var>result</var>. </p>
</ol>
<p>The <dfn class="idl-code" data-dfn-for="HTMLCollection" data-dfn-type="method" data-export="" data-lt="namedItem(name)" id="dom-htmlcollection-nameditem"><code>namedItem(<var>key</var>)</code><a class="self-link" href="#dom-htmlcollection-nameditem"></a></dfn> method, when
invoked, must run these steps: </p>
<ol>
<li>
<p>If <var>key</var> is the empty string, return null. </p>
<li>
<p>Return the first <a data-link-type="dfn" href="#concept-element">element</a> in the <a data-link-type="dfn" href="#concept-collection">collection</a> for which at least one of
the following is true: </p>
<ul>
<li>it has an <a data-link-type="dfn" href="#concept-id">ID</a> which is <var>key</var>;
<li>it is in the <a data-link-type="dfn" href="#html-namespace">HTML namespace</a> and <a data-link-type="dfn" href="#concept-element-attribute-has">has</a> a <a data-link-type="dfn" href="#concept-named-attribute"><code>name</code> attribute</a> whose <a data-link-type="dfn" href="#concept-attribute-value">value</a> is <var>key</var>;
</ul>
<p>or null if there is no such <a data-link-type="dfn" href="#concept-element">element</a>. </p>
</ol>
<h3 class="heading settled" data-level="4.3" id="mutation-observers"><span class="secno">4.3. </span><span class="content">Mutation observers</span><a class="self-link" href="#mutation-observers"></a></h3>
<p>Each <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#unit-of-related-similar-origin-browsing-contexts">unit of related similar-origin browsing contexts</a> has a <dfn data-dfn-type="dfn" data-export="" id="mutation-observer-compound-microtask-queued-flag">mutation observer compound microtask queued flag<a class="self-link" href="#mutation-observer-compound-microtask-queued-flag"></a></dfn> and an associated list of <code class="idl"><a data-link-type="idl" href="#mutationobserver">MutationObserver</a></code> objects which is initially empty. <a data-link-type="biblio" href="#biblio-html">[HTML]</a></p>
<p>To <dfn data-dfn-type="dfn" data-export="" id="queue-a-mutation-observer-compound-microtask">queue a mutation observer compound microtask<a class="self-link" href="#queue-a-mutation-observer-compound-microtask"></a></dfn>, run these steps:</p>
Expand Down Expand Up @@ -5442,7 +5448,7 @@ <h3 class="no-num heading settled" id="normative"><span class="content">Normativ
<dt id="biblio-cssom-view"><a class="self-link" href="#biblio-cssom-view"></a>[CSSOM-VIEW]
<dd>Simon Pieters; Glenn Adams. <a href="http://dev.w3.org/csswg/cssom-view/">CSSOM View Module</a>. 17 December 2013. WD. URL: <a href="http://dev.w3.org/csswg/cssom-view/">http://dev.w3.org/csswg/cssom-view/</a>
<dt id="biblio-encoding"><a class="self-link" href="#biblio-encoding"></a>[ENCODING]
<dd>Anne van Kesteren; Joshua Bell; Addison Phillips. <a href="https://encoding.spec.whatwg.org/">Encoding</a>. 20 October 2015. CR. URL: <a href="https://encoding.spec.whatwg.org/">https://encoding.spec.whatwg.org/</a>
<dd>Anne van Kesteren; Joshua Bell; Addison Phillips. <a href="https://encoding.spec.whatwg.org/">Encoding</a>. 16 September 2014. CR. URL: <a href="https://encoding.spec.whatwg.org/">https://encoding.spec.whatwg.org/</a>
<dt id="biblio-rfc2119"><a class="self-link" href="#biblio-rfc2119"></a>[RFC2119]
<dd>S. Bradner. <a href="https://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a>
<dt id="biblio-selectors-4"><a class="self-link" href="#biblio-selectors-4"></a>[SELECTORS-4]
Expand Down

0 comments on commit eda3dcd

Please sign in to comment.