aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngAnimate/animateSpec.js
diff options
context:
space:
mode:
authorMatias Niemelä2014-02-21 03:43:50 -0500
committerMatias Niemelä2014-02-26 14:53:57 -0500
commite9881991ca0a5019d3a4215477738ed247898ba0 (patch)
tree5bca5a431522715543288b94772882dcd994bbe2 /test/ngAnimate/animateSpec.js
parentc9245cf759108add2a10ffca4d41b1c68c1e8c76 (diff)
downloadangular.js-e9881991ca0a5019d3a4215477738ed247898ba0.tar.bz2
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
Diffstat (limited to 'test/ngAnimate/animateSpec.js')
-rw-r--r--test/ngAnimate/animateSpec.js35
1 files changed, 35 insertions, 0 deletions
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('<div id="parentGuy"></div>')($rootScope);
+ var child = $compile('<div class="going"></div>')($rootScope);
+ $rootElement.append(element);
+ element.append(child);
+
+ $animate.leave(child);
+ $rootScope.$digest();
+
+ expect(stat).toBe('leaving');
+
+ child.remove();
+
+ expect(stat).toBe('gone');
+ });
+ });
});
});