-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($animate): abort class-based animations if the element is removed during digest #8958
Conversation
LGTM |
It should be constant since there is only one element within the jqLite/jQuery wrapper for both the element and $rootElement: https://github.com/angular/angular.js/blob/master/src/ngAnimate/animate.js#L404 |
@@ -1015,6 +1015,15 @@ angular.module('ngAnimate', ['ng']) | |||
} | |||
|
|||
return cache.promise = runAnimationPostDigest(function(done) { | |||
var parentElement; | |||
if (!isMatchingElement(element, $rootElement)) { //$rootElement's parent is not inside of the app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment is likely incorrect. it should be element's parent is not inside of the app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//any ancestor elements past $rootElement's are not apart of the app
I had a similar issue to #8796, but the fix you provided was not enough in my case. The issue was happening in a ngRepeat directive, and I had to check also if the parentElement had the property Here is the piece of code to achieve that: if (!parentElement || parentElement.length === 0 || parentElement[0]['$$NG_REMOVED']) Do you need me to try to reproduce this bug in a plunkr? |
02dc2aa
to
fd2d6c0
Compare
is anyone looking at this issue? One unit test failed but it isn't related to this fix. |
I have got the same problem and your fix is not enough. In my example I use ngTable and I managed to replicate this issue here http://plnkr.co/edit/9Ff6VJBzyyOVKYf3ZlA6 If I try to generate my columns by using ngRepeat the issue is gone. It looks like some elements are created later and the cache object attached to them exist. I excluded jQuery. |
… during digest Prior to this fix, if the element is removed before the digest kicks off then it leads to an error when a class based animation is run. This fix ensures that the animation will not run at all if the element does not have a parent element. Closes angular#8796
38915e2
to
6744cbd
Compare
@demsey2 I can confirm that the changes in my local angular-animate.js file (which was packaged together from the code in this commit) fixes your plunkr issue. |
|
||
//any ancestor elements past $rootElement's are not apart of the | ||
//app therefore there is no need to examine the parent element | ||
if (!isMatchingElement(element, $rootElement)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite get this check. it's not like we are traversing up until the $rootElement (even though the comment above makes it sounds like it).
otherwise lgtm |
thanks @matsko for the fix, I tried with the plunkr example and the issue still exists. I have included a new version of ngAnimate with your fix and I can still see that error for some reasons the "$$NG_REMOVED" in elementNode doesn't exists so an animation can't be completed/done |
@demsey2 looks like it's fixed on master: http://plnkr.co/edit/GFqCAzaVPezmzCcOhCC6?p=preview |
@demsey2 this issue touches another problem and it's fixed with this PR. Your issue on the other hand, while similar, is caused by ngModel. It looks like the snapshot version (the next version of 1.3 RC) fixes it so we should be OK. However if it doesn't then please open a new issue. |
Prior to this fix, if the element is removed before the digest kicks off then it leads
to an error when a class based animation is run. This fix ensures that the animation will
not run at all if the element does not have a parent element.
Closes #8796