aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornanto_vi <nanto@moon.email.ne.jp>2013-01-08 01:02:40 +0900
committernanto_vi <nanto@moon.email.ne.jp>2013-01-08 01:03:38 +0900
commit412d910697f7c33a29066009930e1373fd80b27a (patch)
tree508a368e930cf18b47dd4c5f571198bdbb647252 /src
parente7fdda981928befda72b78e9e2b17e33e232a603 (diff)
downloadjquery-412d910697f7c33a29066009930e1373fd80b27a.tar.gz
jquery-412d910697f7c33a29066009930e1373fd80b27a.zip
Eliminate redundancy of Deferred.then().
Diffstat (limited to 'src')
-rw-r--r--src/deferred.js27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/deferred.js b/src/deferred.js
index 4001c2384..0efc05dc3 100644
--- a/src/deferred.js
+++ b/src/deferred.js
@@ -21,24 +21,19 @@ jQuery.extend({
return jQuery.Deferred(function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) {
var action = tuple[ 0 ],
- fn = fns[ i ];
+ fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
// deferred[ done | fail | progress ] for forwarding actions to newDefer
- deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
- function() {
- var returned = fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise()
- .done( newDefer.resolve )
- .fail( newDefer.reject )
- .progress( newDefer.notify );
- } else {
- newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, [ returned ] );
- }
- } :
- function() {
- newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, arguments );
+ deferred[ tuple[1] ](function() {
+ var returned = fn && fn.apply( this, arguments );
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
+ returned.promise()
+ .done( newDefer.resolve )
+ .fail( newDefer.reject )
+ .progress( newDefer.notify );
+ } else {
+ newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
}
- );
+ });
});
fns = null;
}).promise();