Commit efb98f85 authored by Nicolas HENRY's avatar Nicolas HENRY Committed by Oleg Gaidarenko

Deferred: Fix $.when with resolved deferred and progress callbacks

Ref ab20d9d24f0a95df382c02e9ef3dcc4adb86e4f1
parent 62a333e0
...@@ -133,9 +133,9 @@ jQuery.extend({ ...@@ -133,9 +133,9 @@ jQuery.extend({
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
resolveValues[ i ].promise() resolveValues[ i ].promise()
.progress( updateFunc( i, progressContexts, progressValues ) )
.done( updateFunc( i, resolveContexts, resolveValues ) ) .done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( deferred.reject ) .fail( deferred.reject );
.progress( updateFunc( i, progressContexts, progressValues ) );
} else { } else {
--remaining; --remaining;
} }
......
...@@ -436,3 +436,25 @@ test( "jQuery.when - joined", function() { ...@@ -436,3 +436,25 @@ test( "jQuery.when - joined", function() {
deferreds.futureSuccess.resolve( 1 ); deferreds.futureSuccess.resolve( 1 );
deferreds.futureError.reject( 0 ); deferreds.futureError.reject( 0 );
}); });
test( "jQuery.when - resolved", function() {
expect( 6 );
var a = jQuery.Deferred().notify( 1 ).resolve( 4 ),
b = jQuery.Deferred().notify( 2 ).resolve( 5 ),
c = jQuery.Deferred().notify( 3 ).resolve( 6 );
jQuery.when( a, b, c ).progress(function( a, b, c ) {
strictEqual( a, 1, "first notify value ok" );
strictEqual( b, 2, "second notify value ok" );
strictEqual( c, 3, "third notify value ok" );
}).done(function( a, b, c ) {
strictEqual( a, 4, "first resolve value ok" );
strictEqual( b, 5, "second resolve value ok" );
strictEqual( c, 6, "third resolve value ok" );
}).fail(function() {
ok( false, "Error on resolve" );
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment