Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMLAllCollection: add tags() method #9908

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3275,6 +3275,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort">signal abort</dfn></li>
<li><dfn data-x="AbortSignal-add" data-x-href="https://dom.spec.whatwg.org/#abortsignal-add">add</dfn></li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name">get an attribute by name</dfn> algorithm</li>
<li>The <dfn data-x="concept-getelementsbytagname" data-x-href="https://dom.spec.whatwg.org/#concept-getelementsbytagname">list of elements with qualified name</dfn> algorithm</li>
</ul>

<p>The following features are defined in <cite>UI Events</cite>: <ref>UIEVENTS</ref></p>
Expand Down Expand Up @@ -8661,6 +8662,7 @@ interface <dfn interface>HTMLAllCollection</dfn> {
getter <span>Element</span> (unsigned long index);
getter (<span>HTMLCollection</span> or <span>Element</span>)? <span data-x="dom-HTMLAllCollection-namedItem">namedItem</span>(DOMString name);
(<span>HTMLCollection</span> or <span>Element</span>)? <span data-x="dom-HTMLAllCollection-item">item</span>(optional DOMString nameOrIndex);
HTMLCollection? <span data-x="dom-HTMLAllCollection-tags">tags</span>(DOMString tagName);

// Note: HTMLAllCollection objects have a <a href="#HTMLAllCollection-call">custom [[Call]] internal method</a> and an <span>[[IsHTMLDDA]]</span> internal slot.
};</code></pre>
Expand Down Expand Up @@ -8703,6 +8705,11 @@ interface <dfn interface>HTMLAllCollection</dfn> {
<var>nameOrIndex</var>.</p></li>
</ol>

<p>The <dfn method for="HTMLAllCollection"><code
data-x="dom-HTMLAllCollection-tags">tags(<var>tagName</var>)</code></dfn> method steps are
to return the result of <span data-x="concept-get-all-tags">getting the "all" elements filtered
by tag</span> from <span>this</span> given <var>tagName</var>.</p>

<hr>

<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2837 -->
Expand Down Expand Up @@ -8770,6 +8777,31 @@ interface <dfn interface>HTMLAllCollection</dfn> {
element(s)</span> from <var>collection</var> given <var>nameOrIndex</var>.</p></li>
</ol>

<p>To <dfn data-x="concept-get-all-tags">get the "all" elements filtered by tag</dfn> from an
<code>HTMLAllCollection</code> <var>collection</var> given a <var>tagName</var>, perform the
following steps:</p>

<ol>
<!-- TODO check this in msie -->
<li><p>If <var>tagName</var> is the empty string, return null.</p></li>

<li>
<p>Let <var>subCollection</var> be an <code>HTMLCollection</code> object rooted at the same
<code>Document</code> as <var>collection</var>, whose filter matches only elements that are
in the <span data-x="concept-getelementsbytagname">list of elements with qualified name
tagName</span> for <span>this</span>.</p>
</li>

<!-- TODO check this in msie, but book says this won’t happen -->
<li><p>If there is exactly one element in <var>subCollection</var>, then return that
element.</p></li>

<!-- TODO check this in msie -->
<li><p>Otherwise, if <var>subCollection</var> is empty, return null.</p></li>

<li><p>Otherwise, return <var>subCollection</var>.</p></li>
</ol>

<h6 id="HTMLAllCollection-call">[[Call]] ( <var>thisArgument</var>, <var>argumentsList</var> )</h6>

<ol>
Expand Down