Skip to content

Commit

Permalink
Fix Promise.prototype.then to conform to spec.
Browse files Browse the repository at this point in the history
I assumed there was a think-o in the spec, but the behavior was apparently
intentional.  See https://bugs.ecmascript.org/show_bug.cgi?id=2513
  • Loading branch information
cscott committed Feb 14, 2014
1 parent ea66963 commit a06e548
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@
// If iterable has no items, resulting promise will never
// resolve; see:
// https://github.com/domenic/promises-unwrapping/issues/75
// https://bugs.ecmascript.org/show_bug.cgi?id=2515
break;
}
var nextPromise = C.cast(next.value);
Expand Down Expand Up @@ -1268,7 +1269,9 @@
Promise.prototype.then = function( onFulfilled, onRejected ) {
var promise = this;
if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); }
var C = this._promiseConstructor;
// this.constructor not this._promiseConstructor; see
// https://bugs.ecmascript.org/show_bug.cgi?id=2513
var C = this.constructor;
var capability = new PromiseCapability(C);
if (!ES.IsCallable(onRejected)) {
onRejected = function(e) { throw e; };
Expand Down

0 comments on commit a06e548

Please sign in to comment.