diff --git a/src/effects.js b/src/effects.js index d9e9a8b313..acd3fad9e0 100644 --- a/src/effects.js +++ b/src/effects.js @@ -461,7 +461,8 @@ jQuery.extend( jQuery.fx, { var timers = jQuery.timers; for ( var i = 0; i < timers.length; i++ ) { - if ( !timers[i]() ) { + var timer = timers[i]; + if ( !timer() && timer === timers[i]) { timers.splice(i--, 1); } } diff --git a/test/unit/effects.js b/test/unit/effects.js index c0a812f45c..883e9ae092 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -532,6 +532,25 @@ test("stop(clearQueue, gotoEnd)", function() { }, 100); }); + +test("animate( ..., function(){ stop(); } )", function() { + expect(1); + stop(); + + var $foo = jQuery("#foo"); + $foo.hide().width(200); + + $foo.animate({width: "+=100"}, 100, function(){ + $foo.stop(); + //this animation would be dropped + $foo.animate({width: "+=100"}, 100); + }); + setTimeout(function(){ + ok($foo.width() == 400, "inner stop killed the animation loop"); + start(); + }, 300); +}); + test("toggle()", function() { expect(6); var x = jQuery("#foo");