Skip to main content

Bug Tracker

Side navigation

#3583 closed bug (fixed)

Opened November 08, 2008 01:54PM UTC

Closed September 24, 2010 07:58PM UTC

too much recursion with animate( params, options ) [when options is a var]

Reported by: adrien.gibrat Owned by:
Priority: minor Milestone: 1.4.3
Component: effects Version: 1.4.2
Keywords: aminate, queueing, recursion, Cc:
Blocked by: Blocking:
Description

options.old (set in $.speed for queueing purpose) seems to store too much recursive call and freeze the browser when called more than x times, in firebug error message are:

too much recursion

fn.constructor != Array && /^[\\s[]?function/.test( fn + "" );

in jquery.js (ligne 619)

too much recursion

if ( jQuery.isFunction( opt.old ) )

in jquery.js (ligne 3158)

To resolve this bug:

speed: function(speed, easing, fn) {

var opt = speed && speed.constructor == Object ? speed : {...};

...

should be:

speed: function(speed, easing, fn) {

var opt = speed && speed.constructor == Object ? jQuery.extend({},speed) : {...};

...

Attachments (1)
Change History (5)

Changed May 27, 2010 05:46PM UTC by cdmckay comment:1

I had this problem too.

Basically, if you re-use the "options" parameter object for many animations, you'll get a infinite loop.

Please update the animate() documentation to say that the "options" parameter is modified by animate() and cannot be re-used.

Better yet, why not make animate() make a copy of the "options" parameter object so that this bug will not occur anymore.

Changed May 27, 2010 05:55PM UTC by cdmckay comment:2

This bug still occurs as of 1.4.2.

Changed June 19, 2010 11:34PM UTC by desandro comment:3

Stephen Rushing found a good work-around using $.extend inside $.fn.animate.

var animationOptions = {
    duration: 1000,
    easing: 'linear',
    queue: false
}

$(elem).animate(props, $.extend( true, [], animationOptions) )

Changed August 12, 2010 12:51AM UTC by dmethvin comment:4

Agreed, we should either document options as mutated or make a copy.

Changed September 24, 2010 07:58PM UTC by john comment:5

milestone: 1.31.4.3
resolution: → fixed
status: newclosed
version: 1.2.61.4.2