Bug Tracker

Opened 14 years ago

Closed 12 years ago

#3583 closed bug (fixed)

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:


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)

recursion-animation.html (1.1 KB) - added by adrien.gibrat 14 years ago.

Download all attachments as: .zip

Change History (6)

Changed 14 years ago by adrien.gibrat

Attachment: recursion-animation.html added

comment:2 Changed 13 years ago by cdmckay

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.

comment:3 Changed 13 years ago by cdmckay

This bug still occurs as of 1.4.2.

comment:4 Changed 13 years ago by desandro

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) )

comment:5 Changed 12 years ago by dmethvin

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

comment:6 Changed 12 years ago by john

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.