Opened 12 years ago
Closed 11 years ago
#9217 closed bug (fixed)
javascript error in IE8 when animating element is removed before animation finishes
Reported by: | JorisDebonnet | Owned by: | gnarf |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | effects | Version: | 1.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I had some IE8 users report that my application was sometimes 'crashing', and it took me many, many hours to pinpoint the problem (because all IE8 said was: 'unspecified error' somewhere in jQuery). I should just have used a non-minimized version of jQuery to save me those hours, but anyway.
Apparently, if an element's scrollTop is being animated, and that element is removed during the animation, then jQuery will crash in IE8. In the git at the time of writing, it's on line 8499 in a piece that extends jQuery.fx's step, and says:
fx.elem[ fx.prop ] = fx.now;
http://jsfiddle.net/NGBaX/2/ (note: I always need to run it twice before it crashes)
Change History (11)
comment:1 Changed 12 years ago by
Component: | unfiled → effects |
---|---|
Priority: | undecided → low |
Status: | new → open |
Version: | git → 1.6 |
comment:2 Changed 12 years ago by
Well, yes, the javascript error is what I mean. Since it also affects future animations, at least in my application, I called it a 'crash'. In my application's case, even logging out would not work anymore ... since that does an animation (which only redirects the page upon finishing it).
It does sound sensible of course to stop the animation before removing the element, but it was not obvious to think about it in my case. It's a stylized dropdown in a form that is slid up when an input element is blurred. Makes sense to me, but 'sadly' this element is of course also blurred when the form is submitted via ajax, which (when response is received) overwrites part of the page. And, well, the ajax call seems to return faster than the animation, so it does that. :)
(I temporarily solved my app by simply removing scrollTop from the animation)
So anyway, all this just to say that I do believe it's something a developer should be able to rely on, in complicated systems :)
The point is perhaps that scrollTop is not very often animated, leaving the problem unreported until now.
comment:3 Changed 12 years ago by
Milestone: | 1.next → 1.7 |
---|---|
Owner: | set to gnarf |
Status: | open → assigned |
Originally commented on this pull: https://github.com/jquery/jquery/pull/542#issuecomment-2369920
I really really dislike this "catch and release" pattern here... There HAS to be a better way to fix this bug.
Timmy's suggestion in the bug ticket has some merit, to fix the crash/bug you just need to .stop() the animation before removing the element - which makes sense anyway...
Why are we still animating an element that has been removed? Should these timers be stopped? etc..
If we are going to fix this bug, we should probably be REMOVING the timers from jQuery.timers in cleanData. If not, we need to tell users to .stop() before .remove(), but that has problems. It's probably easier for us to remove timers than it is for the user to .find("*").stop().end().remove();
comment:5 Changed 12 years ago by
Owner: | changed from gnarf to Timmy Willison |
---|
comment:6 Changed 12 years ago by
Milestone: | 1.7 → 1.next |
---|
comment:7 Changed 11 years ago by
Owner: | changed from Timmy Willison to gnarf |
---|
comment:8 Changed 11 years ago by
Milestone: | 1.next → 1.8 |
---|
Gnarf, you mentioned you were going to roll this up into the animation rewrite. The fiddle is still failing on edge.
comment:9 Changed 11 years ago by
Summary: | jQuery crashes in IE8 when scrollTop-animated element is removed → javascript error in IE8 when animating element is removed before animation finishes |
---|
comment:11 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix #9217. oldIE error when changing detached elements, close gh-861
Changeset: 74cc5b0984335532ab272b8286566000c4bf3daf
I'm unable to reproduce the crash, but I do notice a javascript error. Regardless, you should probably stop the animation before the removing the element.