diff options
| author | Matias Niemelä | 2014-02-21 03:43:50 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-02-26 14:53:57 -0500 |
| commit | e9881991ca0a5019d3a4215477738ed247898ba0 (patch) | |
| tree | 5bca5a431522715543288b94772882dcd994bbe2 /test/ng/directive/ngIfSpec.js | |
| parent | c9245cf759108add2a10ffca4d41b1c68c1e8c76 (diff) | |
| download | angular.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/ng/directive/ngIfSpec.js')
| -rwxr-xr-x | test/ng/directive/ngIfSpec.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ng/directive/ngIfSpec.js b/test/ng/directive/ngIfSpec.js index d40e6812..771e264a 100755 --- a/test/ng/directive/ngIfSpec.js +++ b/test/ng/directive/ngIfSpec.js @@ -277,4 +277,42 @@ describe('ngIf animations', function () { expect(element.children().length).toBe(0); })); + it('should destroy the previous leave animation if a new one takes place', function() { + module(function($provide) { + $provide.value('$animate', { + enabled : function() { return true; }, + leave : function() { + //DOM operation left blank + }, + enter : function(element, parent) { + parent.append(element); + } + }); + }); + inject(function ($compile, $rootScope, $animate) { + var item; + var $scope = $rootScope.$new(); + element = $compile(html( + '<div>' + + '<div ng-if="value">Yo</div>' + + '</div>' + ))($scope); + + $scope.$apply('value = true'); + + var destroyed, inner = element.children(0); + inner.on('$destroy', function() { + destroyed = true; + }); + + $scope.$apply('value = false'); + + $scope.$apply('value = true'); + + $scope.$apply('value = false'); + + expect(destroyed).toBe(true); + }); + }); + }); |
