Question : Does this only polyfil if Promise is undefined.
Closed this issue · 5 comments
Hi,
The question is does this only polyfil global Promise if it does not exits. or would simply override native Promise too ?
I would expect that a polyfill checks that the original function already exists. This polyfill seems not to do that, you have to check it for your own, as you can see here: https://github.com/taylorhakes/promise-polyfill#simple-use
Maybe a project member can explain why this approach is better.
There are 2 approaches that this library could take. It could update the window (or global) by default or it could not. If it updates the window by default, users who don't want global pollution can't opt out. If it's not added to the window, users always have the option to opt in.
Recently I think the right answer is to provider both in different files. I will add a polyfill file in the next release.
The question is, why would someone want to have the promise polyfill, if its already natively supported? I prefer a native-check inside, like in many other polyfills out there, to keep the native functionality, when the script is executed anyway. Imho, this way there is no need for a second file.
Maybe I do not understand what's going on in the polyfill and stop arguing now. :-)
Correct @RiZKiT . I am scared if this overrides window.Promise . It should only patch it if it is undefined.
7.0.0 adds a polyfill file. If you would like an automatic polyfill, it is available now.