From e9881991ca0a5019d3a4215477738ed247898ba0 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Fri, 21 Feb 2014 03:43:50 -0500 Subject: fix($animate): ensure that animateable directives cancel expired leave animations If enter -> leave -> enter -> leave occurs then the first leave animation will animate alongside the second. This causes the very first DOM node (the view in ngView for example) to animate at the same time as the most recent DOM node which ends up being an undesired effect. This fix takes care of this issue. Closes #5886 --- test/ngAnimate/animateSpec.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/ngAnimate') diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 55ec4ae8..a30b5fe9 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -3335,5 +3335,40 @@ describe("ngAnimate", function() { expect(cancelReflowCallback).toHaveBeenCalled(); }); }); + + it('should immediately close off a leave animation if the element is removed from the DOM', function() { + var stat; + module(function($animateProvider) { + $animateProvider.register('.going', function() { + return { + leave : function() { + //left blank so it hangs + stat = 'leaving'; + return function(cancelled) { + stat = cancelled && 'gone'; + }; + } + }; + }); + }); + inject(function($sniffer, $compile, $rootScope, $rootElement, $animate, $timeout) { + + $animate.enabled(true); + + var element = $compile('
')($rootScope); + var child = $compile('')($rootScope); + $rootElement.append(element); + element.append(child); + + $animate.leave(child); + $rootScope.$digest(); + + expect(stat).toBe('leaving'); + + child.remove(); + + expect(stat).toBe('gone'); + }); + }); }); }); -- cgit v1.2.3