Deferred: .resolve(), .reject() and .notify() now set the callback context to the promise instance rather than the deferred instance ; .then() has also been amended. Fixes #11405.

This commit is contained in:
jaubourg
2012-12-07 15:14:12 +01:00
parent 282c044d64
commit 23d7cf0488
2 changed files with 9 additions and 6 deletions

View File

@@ -32,7 +32,7 @@ jQuery.extend({
.fail( newDefer.reject )
.progress( newDefer.notify );
} else {
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, [ returned ] );
}
} :
newDefer[ action ]
@@ -70,8 +70,11 @@ jQuery.extend({
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
}
// deferred[ resolve | reject | notify ] = list.fire
deferred[ tuple[0] ] = list.fire;
// deferred[ resolve | reject | notify ]
deferred[ tuple[0] ] = function() {
deferred[ tuple[0] + "With" ]( promise, arguments );
return this;
};
deferred[ tuple[0] + "With" ] = list.fireWith;
});