From 729fc4ff33778c60536f1476fb7ee8bf032ba26d Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Tue, 1 Dec 2015 18:04:16 +0100 Subject: [PATCH] fix(ngAnimate): ignore children without animation runner when closing them During parent structural animations, ongoing animations on child elements are closed. These children are looked up by checking the data-ng-animate attribute. If an element is the clone of an animating element, it might have this attribute, but no animation runner associated with it, so we need to ignore it. Fixes #11992 Closes #13423 --- src/ngAnimate/animateQueue.js | 14 +++++++------- test/ngAnimate/animateSpec.js | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/ngAnimate/animateQueue.js b/src/ngAnimate/animateQueue.js index 04f837c8aaa9..a9b2c8384d13 100644 --- a/src/ngAnimate/animateQueue.js +++ b/src/ngAnimate/animateQueue.js @@ -507,15 +507,15 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { forEach(children, function(child) { var state = parseInt(child.getAttribute(NG_ANIMATE_ATTR_NAME)); var animationDetails = activeAnimationsLookup.get(child); - switch (state) { - case RUNNING_STATE: - animationDetails.runner.end(); - /* falls through */ - case PRE_DIGEST_STATE: - if (animationDetails) { + if (animationDetails) { + switch (state) { + case RUNNING_STATE: + animationDetails.runner.end(); + /* falls through */ + case PRE_DIGEST_STATE: activeAnimationsLookup.remove(child); + break; } - break; } }); } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 9df3b400bdc3..aebe41c963ea 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -850,6 +850,26 @@ describe("animations", function() { expect(isCancelled).toBe(true); })); + it('should ignore an apparently ongoing post-digest child animation that has no animation data', + inject(function($rootScope, $rootElement, $animate) { + + parent.append(element); + + $animate.addClass(element, 'rumlow'); + + $rootScope.$digest(); + expect(capturedAnimation[0]).toBe(element); + + // If an element is cloned during an animation, it still has the data-attributes indicating + // an animation + var clone = element.clone(); + parent.append(clone); + + $animate.move(parent, null, parent2); + $rootScope.$digest(); + expect(capturedAnimation[0]).toBe(parent); + })); + it('should not end any child animations if a parent class-based animation is issued', inject(function($rootScope, $rootElement, $animate) {