Skip to content

Commit efb98f8

Browse files
nicolashenrymarkelog
authored andcommitted
Deferred: Fix $.when with resolved deferred and progress callbacks
Ref ab20d9d
1 parent 62a333e commit efb98f8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/deferred.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ jQuery.extend({
133133
for ( ; i < length; i++ ) {
134134
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
135135
resolveValues[ i ].promise()
136+
.progress( updateFunc( i, progressContexts, progressValues ) )
136137
.done( updateFunc( i, resolveContexts, resolveValues ) )
137-
.fail( deferred.reject )
138-
.progress( updateFunc( i, progressContexts, progressValues ) );
138+
.fail( deferred.reject );
139139
} else {
140140
--remaining;
141141
}

test/unit/deferred.js

Lines changed: 22 additions & 0 deletions
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)