Ticket #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: | |
| 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
Change History
comment:2 Changed 3 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:4 Changed 3 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 3 years ago by dmethvin
Agreed, we should either document options as mutated or make a copy.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

