Permalink
Browse files

Landing pull request 374. .animate() Callbacks should fire in correct…

… order (unit test included). Fixes #9100.

More Details:
 - #374
 - https://github.com/jquery/jquery/issues/9100
  • Loading branch information...
louisremi authored and jeresig committed May 10, 2011
2 parents 304dd61 + 966c2fe commit 521ae562daa8f95def8872a55a260e9bdbc40d8b
Showing with 18 additions and 5 deletions.
  1. +2 −5 src/effects.js
  2. +16 −0 test/unit/effects.js
@@ -258,7 +258,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) {
@@ -522,11 +521,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);
}
}

@@ -1029,3 +1029,19 @@ test( "animate properties missing px w/ opacity as last (#9074)", 2, function()
start();
}, 100);
});

test("callbacks should fire in correct order (#9100)", function() {
stop();
var a = 1,
cb = 0,
$lis = jQuery("<p data-operation='*2'></p><p data-operation='^2'></p>").appendTo("#qunit-fixture")
// The test will always pass if no properties are animated or if the duration is 0
.animate({fontSize: 12}, 13, function() {
a *= jQuery(this).data("operation") === "*2" ? 2 : a;
cb++;
if ( cb === 2 ) {
equal( a, 4, "test value has been *2 and _then_ ^2");
start();
}
});
});

0 comments on commit 521ae56

Please sign in to comment.