diff options
Diffstat (limited to 'src/deferred.js')
-rw-r--r-- | src/deferred.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/deferred.js b/src/deferred.js index 6e4d43b31..73b2f9ef2 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -366,16 +366,21 @@ jQuery.extend( { // Single- and empty arguments are adopted like Promise.resolve if ( remaining <= 1 ) { - adoptValue( singleValue, master.resolve, master.reject ); + adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject ); // Use .then() to unwrap secondary thenables (cf. gh-3000) - return master.then(); + if ( master.state() === "pending" || + jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { + + return master.then(); + } } // Multiple arguments are aggregated like Promise.all array elements while ( i-- ) { adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); } + return master.promise(); } } ); |