Bug Tracker

Opened 10 years ago

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

animatebug.html (2.1 KB) - added by Screeze 10 years ago.
Example code
animatebug.PNG (10.5 KB) - added by Screeze 10 years ago.
object after using animate()

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by Screeze

Attachment: animatebug.html added

Example code

Changed 10 years ago by Screeze

Attachment: animatebug.PNG added

object after using animate()

comment:1 Changed 9 years ago by dmethvin

Component: unfiledfx

comment:2 Changed 9 years ago by Rick Waldron

Owner: set to 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!

comment:3 Changed 9 years ago by jitter

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.

Note: See TracTickets for help on using tickets.