aboutsummaryrefslogtreecommitdiffstats
path: root/src/deferred.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2016-04-15 17:13:59 -0400
committerRichard Gibson <richard.gibson@gmail.com>2016-04-23 00:30:48 -0400
commit76084372c29a59b3fa790ea4d2687f0767514999 (patch)
treed4597330a1373fb0ad65ac866f7ae4fe7ff995ec /src/deferred.js
parent84427591ccffe686f158ce81e5c6ba6694f7da50 (diff)
downloadjquery-76084372c29a59b3fa790ea4d2687f0767514999.tar.gz
jquery-76084372c29a59b3fa790ea4d2687f0767514999.zip
Deferred: Remove default callback context
Employs strict mode to simplify Deferred callback context handling. Fixes gh-3060 Closes gh-3061
Diffstat (limited to 'src/deferred.js')
-rw-r--r--src/deferred.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/deferred.js b/src/deferred.js
index bc2ea8637..91c55a64e 100644
--- a/src/deferred.js
+++ b/src/deferred.js
@@ -4,6 +4,8 @@ define( [
"./callbacks"
], function( jQuery, slice ) {
+"use strict";
+
function Identity( v ) {
return v;
}
@@ -60,7 +62,7 @@ jQuery.extend( {
.fail( newDefer.reject );
} else {
newDefer[ tuple[ 0 ] + "With" ](
- this === promise ? newDefer.promise() : this,
+ this,
fn ? [ returned ] : arguments
);
}
@@ -73,7 +75,7 @@ jQuery.extend( {
var maxDepth = 0;
function resolve( depth, deferred, handler, special ) {
return function() {
- var that = this === promise ? undefined : this,
+ var that = this,
args = arguments,
mightThrow = function() {
var returned, then;
@@ -144,8 +146,7 @@ jQuery.extend( {
// Process the value(s)
// Default process is resolve
- ( special || deferred.resolveWith )(
- that || deferred.promise(), args );
+ ( special || deferred.resolveWith )( that, args );
}
},
@@ -174,8 +175,7 @@ jQuery.extend( {
args = [ e ];
}
- deferred.rejectWith( that || deferred.promise(),
- args );
+ deferred.rejectWith( that, args );
}
}
};
@@ -282,7 +282,7 @@ jQuery.extend( {
// deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) }
deferred[ tuple[ 0 ] ] = function() {
- deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
+ deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
return this;
};