Skip to content

Commit ab20d9d

Browse files
nicolashenrymarkelog
authored andcommitted
Deferred: Fix $.when with resolved deferred and progress callbacks
Fixes jquerygh-1894 Closes jquerygh-1915
1 parent 5a0867d commit ab20d9d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/deferred.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ jQuery.extend({
132132
for ( ; i < length; i++ ) {
133133
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
134134
resolveValues[ i ].promise()
135+
.progress( updateFunc( i, progressContexts, progressValues ) )
135136
.done( updateFunc( i, resolveContexts, resolveValues ) )
136-
.fail( deferred.reject )
137-
.progress( updateFunc( i, progressContexts, progressValues ) );
137+
.fail( deferred.reject );
138138
} else {
139139
--remaining;
140140
}

test/unit/deferred.js

+22
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,25 @@ test( "jQuery.when - joined", function() {
436436
deferreds.futureSuccess.resolve( 1 );
437437
deferreds.futureError.reject( 0 );
438438
});
439+
440+
test( "jQuery.when - resolved", function() {
441+
442+
expect( 6 );
443+
444+
var a = jQuery.Deferred().notify( 1 ).resolve( 4 ),
445+
b = jQuery.Deferred().notify( 2 ).resolve( 5 ),
446+
c = jQuery.Deferred().notify( 3 ).resolve( 6 );
447+
448+
jQuery.when( a, b, c ).progress(function( a, b, c ) {
449+
strictEqual( a, 1, "first notify value ok" );
450+
strictEqual( b, 2, "second notify value ok" );
451+
strictEqual( c, 3, "third notify value ok" );
452+
}).done(function( a, b, c ) {
453+
strictEqual( a, 4, "first resolve value ok" );
454+
strictEqual( b, 5, "second resolve value ok" );
455+
strictEqual( c, 6, "third resolve value ok" );
456+
}).fail(function() {
457+
ok( false, "Error on resolve" );
458+
});
459+
460+
});

0 commit comments

Comments
 (0)