-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Promise.resolve is not bound to Promise object #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's not very convenient, but it's a correct behavior by the spec and FF bug, see step 2 and note. Binding constructor will break subclassing. |
I just figured this out when I saw the check useNative with firefox subclassing. Thanks you for the fast answer. |
I think It's not really true. It's just Still, that's just a side note, as indeed it's how it was specified, but I'm not sure why. |
@medikoo it's really true for a bound, not default constructor, like in |
Thing is that, when it's bound to Unfortunately it's not the case with |
...
It's also interesting for me. @domenic can you explain? |
This is by design. It is as such to make inheritance work, Subclass.resolve(Promise.resolve()).constructor === Subclass |
@stefanpenner sure, it's my answer from the first comment, question here - why SubArray.from([]).constructor === SubArray
Array.from.call(null, []).constructor === Array
SubPromise.resolve(Promise.resolve()).constructor === SubPromise
Promise.resolve.call(null, Promise.resolve()).constructor // Error |
@zloirock thats what i get for quickly reading and answering on my phone :P Now i feel silly. You are correct, |
Running the above line of code throw an error when using core-js.
Using your librabry you get the error : Object is not a function at line 230
Using firefox Promise it returns a promise fullfilled with
undefined
I suggest to bind Promise functions (resolve, reject, race, all) to the constructor.
The text was updated successfully, but these errors were encountered: