Opened 13 years ago
Closed 12 years ago
#6309 closed bug (worksforme)
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)
Change History (5)
Changed 13 years ago by
Attachment: | animatebug.html added |
---|
comment:1 Changed 13 years ago by
Component: | unfiled → fx |
---|
comment:2 Changed 12 years ago by
Owner: | set to Screeze |
---|---|
Priority: | → undecided |
Status: | new → pending |
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!
comment:3 Changed 12 years ago by
Priority: | undecided → low |
---|---|
Resolution: | → worksforme |
Status: | pending → closed |
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.
Example code