Skip to content
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

update polyfill with better native ES6 Promise test #99

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/es6-promise/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,22 @@ export default function polyfill() {

var P = local.Promise;

if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
return;

var nativeES6PromiseSupported =
P &&
// Some of these methods are missing from Firefox/Chrome experimental implementations
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am unsure if we actually support those old/intermediate experimental version?

'resolve' in P && 'reject' in P && 'all' in P && 'race' in P &&
//deprecated API
!('cast' in P) && !('from' in P ) &&
// Older version of the spec had a resolver object as the arg rather than a function
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which browsers does this affect ?

(function(){
var resolve;
new P(function(r){ resolve = r; });
return typeof resolve === 'function';
})();

if (nativeES6PromiseSupported){
return;
}

local.Promise = Promise;
Expand Down