From ddbf594f8ff822281fcd55387885cdf996323387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Thu, 5 Sep 2013 11:59:23 -0400 Subject: [PATCH] fix($animate): ensure that animations are not disabled after $rootElement is animated --- src/ngAnimate/animate.js | 4 +++- test/ngAnimate/animateSpec.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index ca136a504942..a41c76284cb4 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -535,7 +535,9 @@ angular.module('ngAnimate', ['ng']) function done() { if(!done.hasBeenRun) { done.hasBeenRun = true; - element.removeData(NG_ANIMATE_STATE); + if(element != $rootElement) { + element.removeData(NG_ANIMATE_STATE); + } (onComplete || noop)(); } } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 661cc91e87a6..b2fe112e2e21 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1515,4 +1515,21 @@ describe("ngAnimate", function() { }); }); + it("should not remove the animation flag data on $rootElement after an animation is executed", + inject(function($compile, $rootElement, $animate, $document) { + + var stateFlag = '$$ngAnimateState'; + var body = jqLite($document[0].body); + + //this is here since $rootElement is not on the document node + body.data(stateFlag, {}); + body.append($rootElement); + + expect(isObject($rootElement.data(stateFlag))).toBe(true); + + $animate.addClass($rootElement, 'parent'); + + expect(isObject($rootElement.data(stateFlag))).toBe(true); + })); + });