From 076c347605c752821dfb6457044df4ba87b601c1 Mon Sep 17 00:00:00 2001 From: louisremi Date: Mon, 9 May 2011 17:35:51 +0200 Subject: [PATCH 1/3] .animate() Callbacks should fire in correct order (fix #9100 + unit test) --- src/effects.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/effects.js b/src/effects.js index 832ef5da..95600508 100644 --- a/src/effects.js +++ b/src/effects.js @@ -253,7 +253,6 @@ jQuery.fn.extend({ if ( !gotoEnd ) { jQuery._unmark( true, this ); } - // go in reverse order so anything added to the queue during the loop is ignored while ( i-- ) { if ( timers[i].elem === this ) { if (gotoEnd) { @@ -517,11 +516,9 @@ jQuery.fx.prototype = { jQuery.extend( jQuery.fx, { tick: function() { - var timers = jQuery.timers, - i = timers.length; - while ( i-- ) { + for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) { if ( !timers[i]() ) { - timers.splice(i, 1); + timers.splice(i--, 1); } } From f34a90b3f7a5d54beb267ce08295cb1e64c3a2af Mon Sep 17 00:00:00 2001 From: louisremi Date: Mon, 9 May 2011 17:46:00 +0200 Subject: [PATCH 2/3] oops unit test --- test/unit/effects.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/effects.js b/test/unit/effects.js index d0518217..f015fc91 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -993,3 +993,20 @@ test("animate unit-less properties (#4966)", 2, function() { start(); }); }); + +test("callbacks should fire in correct order (#9100)", function() { + stop(); + var a = 1, + cb = 0, + $lis = jQuery("

").appendTo("#qunit-fixture") + // The test will always pass if no properties are animated or if the duration is 0 + .animate({fontSize: 12}, 13, function() { + console.log(jQuery(this).data("operation")) + a *= jQuery(this).data("operation") === "*2" ? 2 : a; + cb++; + if ( cb === 2 ) { + equal( a, 4, "test value has been *2 and _then_ ^2"); + start(); + } + }); +}); \ No newline at end of file From 966c2fe46a785a2555ec9a1048fc4a9014c40aa3 Mon Sep 17 00:00:00 2001 From: louisremi Date: Tue, 10 May 2011 12:18:40 +0200 Subject: [PATCH 3/3] oops console --- test/unit/effects.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/effects.js b/test/unit/effects.js index f015fc91..6fbbbfe3 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1001,7 +1001,6 @@ test("callbacks should fire in correct order (#9100)", function() { $lis = jQuery("

").appendTo("#qunit-fixture") // The test will always pass if no properties are animated or if the duration is 0 .animate({fontSize: 12}, 13, function() { - console.log(jQuery(this).data("operation")) a *= jQuery(this).data("operation") === "*2" ? 2 : a; cb++; if ( cb === 2 ) {