Skip to main content

Bug Tracker

Side navigation

#6309 closed bug (worksforme)

Opened March 18, 2010 01:24PM UTC

Closed November 22, 2010 01:53AM UTC

Using .animate() with .data() -> stack overflow

Reported by: Screeze Owned by: Screeze
Priority: low Milestone: 1.4.3
Component: effects Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

If you store the options and properties for el.animate() in el.data(), it will end up in an stack overflow.

jQuery version: 1.4.2.min

Firefox version: 3.6

The way i used it:

I stored the information in data() on pageload. When calling the animate function, i recieve them from data(), and pass them to animate().

This works, if you only call the animate function once. (e.g. to hide a div)

If you call it again in order to show the div, you will have firefox posting endless "too much recursion" errors in the console, until you close the tab.

I think i found the reason why:

Before animate() is called, the "animationoptions" object in .data() only is: { 'duration' : 150 }

After the call, there are 2 more elements in the object:

old: undefined

complete: function()

(see attached picture)

The function directs to the jQuery-core, I can't give you more information using the min-version.

Based on this information, i was able to build a workaround:

When receiving the info from data(), i clone the objects using extend(), and pass the clone to animate().

I attach an example to reproduce this.

There are 2 buttons, one calls the buggy version on a div, and one calls the version with workaround on another div. Both divs get the same information on pageload.

Make sure you try to click the buttons more then 1 time, and watch firebug console.

Attachments (2)
  • animatebug.PNG (10.5 KB) - added by Screeze March 18, 2010 01:25PM UTC.

    object after using animate()

  • animatebug.html (2.1 KB) - added by Screeze March 18, 2010 01:25PM UTC.

    Example code

Change History (3)

Changed June 15, 2010 12:55AM UTC by dmethvin comment:1

component: unfiledfx

Changed November 01, 2010 09:28PM UTC by rwaldron comment:2

owner: → Screeze
priority: → undecided
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!

Changed November 22, 2010 01:53AM UTC by jitter comment:3

priority: undecidedlow
resolution: → worksforme
status: pendingclosed

I tried your test case (reproduced test data on jsfiddle.net).

Tried it with Opera 10.63, FF 3.6.12 and Chrome. Clicking both buttons multiple times the animations seem to work as expected. No freezing, no too much recursion, no stackoverflow.

If you feel this ticket was closed incorrectly or this issue still persists for you with the newest jQuery version, feel free to report back with a reproducible test case and reopen the issue.