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

Commit d30ae2b

Browse files
rewrite funky setter and abstract as an AO
1 parent 7d48c43 commit d30ae2b

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

spec.html

Lines changed: 26 additions & 16 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

@@ -303,14 +327,7 @@ <h1>get Iterator.prototype.constructor</h1>
303327
<h1>set Iterator.prototype.constructor</h1>
304328
<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>
305329
<emu-alg>
306-
1. Let _O_ be ? RequireObjectCoercible(*this* value).
307-
1. If _O_ is %Iterator.prototype%, then
308-
1. Throw a *TypeError* exception.
309-
1. Let _desc_ be ? _O_.[[GetOwnProperty]](*"constructor"*).
310-
1. If IsDataDescriptor(_desc_) is *true* and _desc_.[[Writable]] is *false*, then
311-
1. Throw a *TypeError* exception.
312-
1. Let _newDesc_ be the PropertyDescriptor { [[Value]]: _v_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
313-
1. Perform ? _O_.[[DefineOwnProperty]](*"constructor"*, _newDesc_).
330+
1. Perform ? SetterThatIgnoresPrototypeProperties(%Iterator.prototype%, *"constructor"*, _v_)
314331
1. Return *undefined*.
315332
</emu-alg>
316333
</emu-clause>
@@ -605,14 +622,7 @@ <h1>get Iterator.prototype [ @@toStringTag ]</h1>
605622
<h1>set Iterator.prototype [ @@toStringTag ]</h1>
606623
<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>
607624
<emu-alg>
608-
1. Let _O_ be ? RequireObjectCoercible(*this* value).
609-
1. If _O_ is %Iterator.prototype%, then
610-
1. Throw a *TypeError* exception.
611-
1. Let _desc_ be ? _O_.[[GetOwnProperty]](@@toStringTag).
612-
1. If IsDataDescriptor(_desc_) is *true* and _desc_.[[Writable]] is *false*, then
613-
1. Throw a *TypeError* exception.
614-
1. Let _newDesc_ be the PropertyDescriptor { [[Value]]: _v_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
615-
1. Perform ? _O_.[[DefineOwnProperty]](@@toStringTag, _newDesc_).
625+
1. Perform ? SetterThatIgnoresPrototypeProperties(%Iterator.prototype%, %Symbol.toStringTag%, _v_)
616626
1. Return *undefined*.
617627
</emu-alg>
618628
</emu-clause>

0 commit comments

Comments
 (0)