Closed
Bug 1170742
Opened 10 years ago
Closed 10 years ago
Update Promise.resolve to match latest spec (no [[PromiseConstructor]])
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: cscott, Unassigned)
References
Details
TC39 agreed to get rid of the hidden [[PromiseConstructor]] property from the spec and simplify `Promise.resolve`. The adopted proposal also makes Promise.resolve ignore "species":
https://esdiscuss.org/topic/fixing-promise-resolve
Opening an issue to track adoption of the new semantics.
Steps to reproduce:
Execute this in the console:
p = Promise.resolve(5);
p.constructor = {}
p2 = Promise.resolve(p)
p===p2
Actual results:
"true"
Expected results:
According to latest spec, p===p2 should be "false".
Comment 1•10 years ago
|
||
We don't really implement the old semantics, for what it's worth. I'm guessing that we'll update some of this stuff as we implement Promise subclassing, though.
For what it's worth, you can implement the proper semantics now -- Promise.resolve() no longer depends on the details of subclassing, it uses a simple test of the "constructor" property.
As you can tell by the test case above, Firefox *does* currently implement the "hidden [[PromiseConstructor]] field" semantics of the old spec, which were errata'ed out of existence. So it's worth changing in the near term to prevent this wrong behavior from spreading.
Comment 3•10 years ago
|
||
Sure. If the promise subclassing stuff doesn't turn out to be near-term (like a month or so), we can fix this up separately. But I suspect it'll be near-term.
Comment 4•10 years ago
|
||
Fixed in bug 1170760.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
| Assignee | ||
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•