This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
make @@toStringTag and constructor prototype properties funky accessors #287
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e298671
make @@toStringTag and constructor prototype properties funky accessors
michaelficarra f481720
throw instead of silently doing nothing
michaelficarra 7d48c43
throw when this value is Iterator.prototype
michaelficarra d741076
rewrite funky setter and extract as an AO
michaelficarra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,7 +289,35 @@ <h1>Iterator.prototype</h1> | |
|
||
<emu-clause id="sec-iteratorprototype.constructor"> | ||
<h1>Iterator.prototype.constructor</h1> | ||
<p>The initial value of %Iterator.prototype%.constructor is %Iterator%.</p> | ||
<p>`Iterator.prototype.constructor` is an accessor property with attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }. The [[Get]] and [[Set]] attributes are defined as follows:</p> | ||
|
||
<emu-clause id="sec-get-iteratorprototype-constructor"> | ||
<h1>get Iterator.prototype.constructor</h1> | ||
<p>The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:</p> | ||
<emu-alg> | ||
1. Return %Iterator%. | ||
</emu-alg> | ||
</emu-clause> | ||
|
||
<emu-clause id="sec-set-iteratorprototype-constructor"> | ||
<h1>set Iterator.prototype.constructor</h1> | ||
<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> | ||
<emu-alg> | ||
1. Let _O_ be ? RequireObjectCoercible(*this* value). | ||
1. If _O_ is %Iterator.prototype%, then | ||
1. Return *undefined*. | ||
1. Let _desc_ be ? _O_.[[GetOwnProperty]](*"constructor"*). | ||
1. If IsDataDescriptor(_desc_) is *true* and _desc_.[[Writable]] is *false*, then | ||
1. Return *undefined*. | ||
1. Let _newDesc_ be the PropertyDescriptor { [[Value]]: _v_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }. | ||
1. Perform ? _O_.[[DefineOwnProperty]](*"constructor"*, _newDesc_). | ||
1. Return *undefined*. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we're really going to do this it should be an AO that many things can share, since the only things that potentially change are Iterator.prototype and the property name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that can be an editorial thing we address in the PR to 262 |
||
</emu-alg> | ||
</emu-clause> | ||
|
||
<emu-note> | ||
<p>Unlike the *"constructor"* property on most built-in prototypes, for web-compatibility reasons this property must be an accessor.</p> | ||
</emu-note> | ||
</emu-clause> | ||
|
||
<emu-clause id="sec-iteratorprototype.map"> | ||
|
@@ -563,9 +591,34 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1> | |
|
||
<emu-clause id="sec-iteratorprototype-@@tostringtag"> | ||
<h1>Iterator.prototype [ @@toStringTag ]</h1> | ||
<p>The initial value of the @@toStringTag property is the String value "Iterator".</p> | ||
<p>`Iterator.prototype[@@toStringTag]` is an accessor property with attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }. The [[Get]] and [[Set]] attributes are defined as follows:</p> | ||
|
||
<emu-clause id="sec-get-iteratorprototype-@@tostringtag"> | ||
<h1>get Iterator.prototype [ @@toStringTag ]</h1> | ||
<p>The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:</p> | ||
<emu-alg> | ||
1. Return *"Iterator"*. | ||
</emu-alg> | ||
</emu-clause> | ||
|
||
<emu-clause id="sec-set-iteratorprototype-@@tostringtag"> | ||
<h1>set Iterator.prototype [ @@toStringTag ]</h1> | ||
<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> | ||
<emu-alg> | ||
1. Let _O_ be ? RequireObjectCoercible(*this* value). | ||
1. If _O_ is %Iterator.prototype%, then | ||
1. Return *undefined*. | ||
1. Let _desc_ be ? _O_.[[GetOwnProperty]](@@toStringTag). | ||
1. If IsDataDescriptor(_desc_) is *true* and _desc_.[[Writable]] is *false*, then | ||
1. Return *undefined*. | ||
1. Let _newDesc_ be the PropertyDescriptor { [[Value]]: _v_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }. | ||
1. Perform ? _O_.[[DefineOwnProperty]](@@toStringTag, _newDesc_). | ||
1. Return *undefined*. | ||
</emu-alg> | ||
</emu-clause> | ||
|
||
<emu-note> | ||
<p>Unlike the @@toStringTag on most built-in classes, for web-compatibility reasons this property must be writable.</p> | ||
<p>Unlike the @@toStringTag property on most built-in prototypes, for web-compatibility reasons this property must be an accessor.</p> | ||
</emu-note> | ||
</emu-clause> | ||
</emu-clause> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per request of @erights this should be an error, to emulate strict rather than sloppy assignment.