Comments (10)
No, I'm not. I was just running the raw implementation (which as you said, is not designed for this purpose) for interest sake, and came across this and was curious as to why it was failing. Now I understand why, and learnt some stuff in the process. As you rightly point out, this case should never happen within the design of es6-shim.
from es6-shim.
Those lines match the spec, eg: https://www.ecma-international.org/ecma-262/6.0/#sec-promise.prototype.then
I believe the real issue is that the ES.SpeciesConstructor
method is broken -- and I bet it has something to do with your runtime environment partially implementing Species support and thus fooling the shim. What platform are you running the tests on?
from es6-shim.
I'm on Node 8.11.4, but I tried on 10 and 12 too. What I did was at
https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L2624
I added globals.PromiseShim = PromiseShim;
This gives me the implementation on the global.
then in subclass.js
I replaced Promise
with PromiseShim
to use the implementation.
So, I kind of expected the implementation to pass all tests, perhaps there is is a good reason why it does not. But making those changes in my original post this.constructor
, then the tests pass.
Why would I do this you ask, well I was interested about the inner workings of Promise, and I'm a tinkerer. :)
from es6-shim.
The shims are not designed to be manually installed; if you just replace the global Promise, many things won't work - since that full replacement is only meant to be used on nodes that never had it to begin with.
from es6-shim.
In other words, the es6-shim must be used in its entirety, or not at all.
from es6-shim.
I appreciate that the library is to be used in its entirety. This is something that I came across while experimenting. Still, I find it strange that this should fail, and I thought it was worth mentioning.
from es6-shim.
Ok, so PromiseShim
does not define Symbol.species
. That seems to be the answer?
from es6-shim.
Sure - I assume because that symbol doesn't exist where Promise
needs to be wholesale replaced.
from es6-shim.
Yep, I added to PromiseShim
if (supportsDescriptors) {
Object.defineProperty(Promise, symbolSpecies, {
configurable: false,
enumerable: false,
get: function() {
return this;
}
});
} else {
object[symbolSpecies] = function() {
return this;
};
}
https://www.ecma-international.org/ecma-262/6.0/#sec-get-promise-@@species
and now all tests pass.
So my question is answered. I'm not saying anything is broken in the shim, as it works, but worth a note.
from es6-shim.
If you’re suggesting there’s an engine which, after including the entire es6-shim, has Symbol.species but doesn’t have it on Promise, then i would consider that a bug.
from es6-shim.
Related Issues (20)
- Support for Promise.prototype.finally HOT 2
- Symbol.split polyfill poor performance HOT 1
- Question: Template literals supported? HOT 4
- Possible to only use needed components? HOT 1
- Function.prototype.name getter brokes function name getter HOT 2
- native Promise broken in node 10.0 and 10.1 HOT 1
- Unneeded argument for overrideNative HOT 2
- For statement doesn't loop? HOT 4
- Shimmed Symbol.iterator is not recognized HOT 10
- TypeError: Object doesn't support property or method 'next' in IE browser HOT 10
- Does the array `of` shim apply to `for...of`? HOT 3
- WhiteSource warning - jQuery Vulnerability CVE-2020-11022 HOT 3
- babel-polyfill and es6-shim HOT 8
- Allowed iterator on empty object HOT 2
- Promise shim missing finally method HOT 1
- This software has new code recently, but no new version has been released. Will there be a new version released recently? HOT 4
- [spam]
- About update a new release HOT 3
- Documentation Icon Errors and typos HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from es6-shim.