Skip to content

Commit

Permalink
Define document.all as having [[IsHTMLDDA]]
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyGu committed Oct 2, 2017
1 parent f3d90c5 commit e324acc
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-sharedarraybuffer-objects"><code>SharedArrayBuffer</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror"><code>TypeError</code></dfn> class</li>
<li>The <dfn data-x="js-RangeError" data-x-href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror"><code>RangeError</code></dfn> class</li>
<li>The <dfn data-x="js-IsHTMLDDA" data-x-href="https://tc39.github.io/ecma262/#sec-IsHTMLDDA-internal-slot">[[IsHTMLDDA]]</dfn> internal slot</li>
<li>The <dfn data-x="js-typeof" data-x-href="https://tc39.github.io/ecma262/#sec-typeof-operator"><code>typeof</code></dfn> operator</li>
<li><dfn data-x-href="https://tc39.github.io/ecma262/#table-49">The <var>TypedArray</var> Constructors</dfn> table</li>
</ul>
Expand Down Expand Up @@ -7160,15 +7161,48 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
different (ab)uses of its methods to all end up returning something, and that it can be called as
a function as an alternative to property access.</p>

<p w-nodev>Objects that implement the <code>HTMLAllCollection</code> interface are <span
data-x="legacy platform object">legacy platform objects</span> with an additonal [[Call]] internal
method described in the <a href="#HTMLAllCollection-call">section below</a>.</p>

<p class="note">All <code>HTMLAllCollection</code> objects are rooted at a <code>Document</code>
and have a filter that matches all elements, so the elements <span>represented by the
collection</span> of an <code>HTMLAllCollection</code> object consist of all the descendant
elements of the root <code>Document</code>.</p>

<p w-nodev>Objects that implement the <code>HTMLAllCollection</code> interface are <span
data-x="legacy platform object">legacy platform objects</span> with an additonal [[Call]] internal
method described in the <a href="#HTMLAllCollection-call">section below</a>. They also have an
<span data-x="js-IsHTMLDDA">[[IsHTMLDDA]]</span> internal slot.</p>

<div class="note">

<p>Objects that implement the <code>HTMLAllCollection</code> interface have several unusual
behaviors, due of the fact that they have an <span data-x="js-IsHTMLDDA">[[IsHTMLDDA]]</span>
internal slot:</p>

<ul>

<li><p>The <span data-x="js-ToBoolean">ToBoolean</span> abstract operation in JavaScript returns
false when given objects implementing the <code>HTMLAllCollection</code> interface.</p></li>

<li><p>The <span data-x="js-abstract-equality">Abstract Equality Comparison</span> algorithm,
when given objects implementing the <code>HTMLAllCollection</code> interface, returns true when
compared to the <code data-x="">undefined</code> and <code data-x="">null</code> values.
(Comparisons using the <span data-x="js-strict-equality">Strict Equality Comparison</span>
algorithm, and Abstract Equality comparisons to other values such as strings or objects, are
unaffected.)</p></li>

<li><p>The <code data-x="js-typeof">typeof</code> operator in JavaScript returns the string
<code data-x="">"undefined"</code> when applied to objects implementing the
<code>HTMLAllCollection</code> interface.</p></li>

</ul>

<p>These special behaviors are motivated by a desire for compatibility with two classes of legacy
content: one that uses the presence of <code data-x="dom-document-all">document.all</code> as a
way to detect legacy user agents, and one that only supports those legacy user agents and uses
the <code data-x="dom-document-all">document.all</code> object without testing for its presence
first. <ref spec=JAVASCRIPT></p>

</div>

<pre class="idl">[Exposed=Window,
LegacyUnenumerableNamedProperties]
interface <dfn>HTMLAllCollection</dfn> {
Expand All @@ -7177,7 +7211,7 @@ interface <dfn>HTMLAllCollection</dfn> {
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);

// Note: HTMLAllCollection objects have a <a href="#HTMLAllCollection-call">custom [[Call]] internal method</a>.
// Note: HTMLAllCollection objects have a <a href="#HTMLAllCollection-call">custom [[Call]] internal method</a> and an <span data-x="js-IsHTMLDDA">[[IsHTMLDDA]]</span> internal slot.
};</pre>

<dl class="domintro">
Expand Down Expand Up @@ -114107,38 +114141,6 @@ interface <dfn>HTMLFontElement</dfn> : <span>HTMLElement</span> {
<code>HTMLAllCollection</code> rooted at the <code>Document</code> node, whose filter matches all
elements.</p>

<p>The object returned for <code data-x="dom-document-all">all</code> has several unusual
behaviors:</p>

<ul>

<li><p>The user agent must act as if the <span data-x="js-ToBoolean">ToBoolean</span> abstract
operation in JavaScript returns false when given the object returned for <code
data-x="dom-document-all">all</code>.</p></li>

<li><p>The user agent must act as if the <span data-x="js-abstract-equality">Abstract Equality
Comparison</span> algorithm, when given the object returned for <code
data-x="dom-document-all">all</code>, returns true when compared to the <code
data-x="">undefined</code> and <code data-x="">null</code> values. (Comparisons using the <span
data-x="js-strict-equality">Strict Equality Comparison</span> algorithm, and Abstract Equality
comparisons to other values such as strings or objects, are unaffected.)</p></li>

<li><p>The user agent must act such that the <code data-x="js-typeof">typeof</code> operator in
JavaScript returns the string <code data-x="">"undefined"</code> when applied to the object
returned for <code data-x="dom-document-all">all</code>.</p></li>

</ul>

<p class="note">These requirements are a <span>willful violation</span> of the JavaScript
specification current at the time of writing. The JavaScript specification
requires that <span data-x="js-ToBoolean">ToBoolean</span> return true for all objects, and does not have
provisions for objects acting as if they were <code data-x="">undefined</code> for the purposes of
certain operators. This violation is motivated by a desire for compatibility with two classes of
legacy content: one that uses the presence of <code data-x="dom-document-all">document.all</code>
as a way to detect legacy user agents, and one that only supports those legacy user agents and
uses the <code data-x="dom-document-all">document.all</code> object without testing for its
presence first. <ref spec=JAVASCRIPT></p>

<hr>

<pre class="idl">partial interface <span id="Window-partial">Window</span> {
Expand Down

0 comments on commit e324acc

Please sign in to comment.