Bug Tracker

Ticket #3583 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

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

Change History

Changed 6 years ago by adrien.gibrat

comment:2 Changed 4 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 4 years ago by cdmckay

This bug still occurs as of 1.4.2.

comment:4 Changed 4 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 4 years ago by dmethvin

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

comment:6 Changed 4 years ago by john

  • Status changed from new to closed
  • Version changed from 1.2.6 to 1.4.2
  • Resolution set to fixed
  • Milestone changed from 1.3 to 1.4.3
Note: See TracTickets for help on using tickets.