Skip to content

Commit

Permalink
Use the entire Promise.prototype.done polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
gabelevi committed Sep 14, 2016
1 parent 6d0e257 commit 46e9fa4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/fbjs/src/core/Deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ class Deferred<Tvalue, Treason> {
}

done(): void {
Promise.prototype.then.apply(this._promise, arguments);
// Embed the polyfill for the non-standard Promise.prototype.done so that
// users of the open source fbjs don't need a custom lib for Promise
const self = arguments.length ?
this._promise.then.apply(this._promise, arguments) :
this._promise;
self.then(undefined, function(err) {
setTimeout(function() {
throw err;
}, 0);
});
}

isSettled(): boolean {
Expand Down

0 comments on commit 46e9fa4

Please sign in to comment.