Skip to content

Commit

Permalink
[Bugfix] ensure RSVP.on(‘error is correctly unsubscribed
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Jun 2, 2014
1 parent 787525f commit 226ccb1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/rsvp/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ define('rsvp/-internal', [
}, promise);
}
function handleOwnThenable(promise, thenable) {
promise._onerror = null;
if (thenable._state === FULFILLED) {
fulfill(promise, thenable._result);
} else if (promise._state === REJECTED) {
Expand Down Expand Up @@ -134,6 +135,7 @@ define('rsvp/-internal', [
function subscribe(parent, child, onFulfillment, onRejection) {
var subscribers = parent._subscribers;
var length = subscribers.length;
parent._onerror = null;
subscribers[length] = child;
subscribers[length + FULFILLED] = onFulfillment;
subscribers[length + REJECTED] = onRejection;
Expand Down Expand Up @@ -539,6 +541,7 @@ define('rsvp/enumerator', [
var c = this._instanceConstructor;
if (isMaybeThenable(entry)) {
if (entry.constructor === c && entry._state !== PENDING) {
entry._onerror = null;
this._settledAt(entry._state, i, entry._result);
} else {
this._willSettleAt(c.resolve(entry), i);
Expand Down

0 comments on commit 226ccb1

Please sign in to comment.