Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit 30b3501

Browse files
make @@toStringTag and constructor prototype properties funky accessors (#287)
1 parent 257f4ea commit 30b3501

File tree

1 file changed

+66
-3
lines changed

1 file changed

+66
-3
lines changed

spec.html

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ <h1>Well-Known Intrinsic Objects</h1>
107107
<emu-clause id="sec-abstract-operations">
108108
<h1>Abstract Operations</h1>
109109

110+
<emu-clause id="sec-SetterThatIgnoresPrototypeProperties" type="abstract operation">
111+
<h1>
112+
SetterThatIgnoresPrototypeProperties (
113+
_home_: an Object,
114+
_p_: a property key,
115+
_v_: an ECMAScript language value,
116+
): either a normal completion containing ~unused~ or a throw completion
117+
</h1>
118+
<dl class="header">
119+
</dl>
120+
<emu-alg>
121+
1. Let _O_ be ? RequireObjectCoercible(*this* value).
122+
1. If _O_ is _home_, then
123+
1. NOTE: Throwing here emulates assignment to a non-writable data property on the _home_ object in strict mode code.
124+
1. Throw a *TypeError* exception.
125+
1. Let _desc_ be ? _O_.[[GetOwnProperty]](_p_).
126+
1. If _desc_ is *undefined*, then
127+
1. Perform ? CreateDataPropertyOrThrow(_O_, _p_, _v_).
128+
1. Else,
129+
1. Perform ? Set(_O_, _p_, _v_, *true*).
130+
1. Return ~unused~.
131+
</emu-alg>
132+
</emu-clause>
133+
110134
<emu-clause id="sec-operations-on-iterator-objects">
111135
<h1>Operations on Iterator Objects</h1>
112136

@@ -289,7 +313,28 @@ <h1>Iterator.prototype</h1>
289313

290314
<emu-clause id="sec-iteratorprototype.constructor">
291315
<h1>Iterator.prototype.constructor</h1>
292-
<p>The initial value of %Iterator.prototype%.constructor is %Iterator%.</p>
316+
<p>`Iterator.prototype.constructor` is an accessor property with attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }. The [[Get]] and [[Set]] attributes are defined as follows:</p>
317+
318+
<emu-clause id="sec-get-iteratorprototype-constructor">
319+
<h1>get Iterator.prototype.constructor</h1>
320+
<p>The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:</p>
321+
<emu-alg>
322+
1. Return %Iterator%.
323+
</emu-alg>
324+
</emu-clause>
325+
326+
<emu-clause id="sec-set-iteratorprototype-constructor">
327+
<h1>set Iterator.prototype.constructor</h1>
328+
<p>The value of the [[Set]] attribute is a built-in function that takes an argument _v_. It performs the following steps when called:</p>
329+
<emu-alg>
330+
1. Perform ? SetterThatIgnoresPrototypeProperties(%Iterator.prototype%, *"constructor"*, _v_).
331+
1. Return *undefined*.
332+
</emu-alg>
333+
</emu-clause>
334+
335+
<emu-note>
336+
<p>Unlike the *"constructor"* property on most built-in prototypes, for web-compatibility reasons this property must be an accessor.</p>
337+
</emu-note>
293338
</emu-clause>
294339

295340
<emu-clause id="sec-iteratorprototype.map">
@@ -563,9 +608,27 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1>
563608

564609
<emu-clause id="sec-iteratorprototype-@@tostringtag">
565610
<h1>Iterator.prototype [ @@toStringTag ]</h1>
566-
<p>The initial value of the @@toStringTag property is the String value "Iterator".</p>
611+
<p>`Iterator.prototype[@@toStringTag]` is an accessor property with attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }. The [[Get]] and [[Set]] attributes are defined as follows:</p>
612+
613+
<emu-clause id="sec-get-iteratorprototype-@@tostringtag">
614+
<h1>get Iterator.prototype [ @@toStringTag ]</h1>
615+
<p>The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:</p>
616+
<emu-alg>
617+
1. Return *"Iterator"*.
618+
</emu-alg>
619+
</emu-clause>
620+
621+
<emu-clause id="sec-set-iteratorprototype-@@tostringtag">
622+
<h1>set Iterator.prototype [ @@toStringTag ]</h1>
623+
<p>The value of the [[Set]] attribute is a built-in function that takes an argument _v_. It performs the following steps when called:</p>
624+
<emu-alg>
625+
1. Perform ? SetterThatIgnoresPrototypeProperties(%Iterator.prototype%, %Symbol.toStringTag%, _v_).
626+
1. Return *undefined*.
627+
</emu-alg>
628+
</emu-clause>
629+
567630
<emu-note>
568-
<p>Unlike the @@toStringTag on most built-in classes, for web-compatibility reasons this property must be writable.</p>
631+
<p>Unlike the @@toStringTag property on most built-in prototypes, for web-compatibility reasons this property must be an accessor.</p>
569632
</emu-note>
570633
</emu-clause>
571634
</emu-clause>

0 commit comments

Comments
 (0)