From e48729251f6d16ecea2f103d96b2c49a203e2712 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 30 Sep 2014 16:14:00 -0700 Subject: [PATCH] refactor(ngView): remove previousElement bookkeeping it's unnecessary and inconsistent (because finishing animations reset we see situations where not previousElement is not always removed and more than one leave animation is going on at the same time). Closes #7606 Closes #9355 --- src/ngRoute/directive/ngView.js | 10 +------ test/ngRoute/directive/ngViewSpec.js | 42 ---------------------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/src/ngRoute/directive/ngView.js b/src/ngRoute/directive/ngView.js index 747a994e3d41..d88ca2b5619a 100644 --- a/src/ngRoute/directive/ngView.js +++ b/src/ngRoute/directive/ngView.js @@ -188,7 +188,6 @@ function ngViewFactory( $route, $anchorScroll, $animate) { link: function(scope, $element, attr, ctrl, $transclude) { var currentScope, currentElement, - previousElement, autoScrollExp = attr.autoscroll, onloadExp = attr.onload || ''; @@ -196,19 +195,12 @@ function ngViewFactory( $route, $anchorScroll, $animate) { update(); function cleanupLastView() { - if(previousElement) { - previousElement.remove(); - previousElement = null; - } if(currentScope) { currentScope.$destroy(); currentScope = null; } if(currentElement) { - $animate.leave(currentElement).then(function() { - previousElement = null; - }); - previousElement = currentElement; + $animate.leave(currentElement); currentElement = null; } } diff --git a/test/ngRoute/directive/ngViewSpec.js b/test/ngRoute/directive/ngViewSpec.js index 6113a2ca2ec8..f4f5e9b0bf39 100644 --- a/test/ngRoute/directive/ngViewSpec.js +++ b/test/ngRoute/directive/ngViewSpec.js @@ -844,48 +844,6 @@ describe('ngView animations', function() { } }); }); - - it('should destroy the previous leave animation if a new one takes place', function() { - module(function($provide) { - $provide.decorator('$animate', function($delegate, $$q) { - var emptyPromise = $$q.defer().promise; - $delegate.leave = function() { - return emptyPromise; - }; - return $delegate; - }); - }); - inject(function ($compile, $rootScope, $animate, $location) { - var item; - var $scope = $rootScope.$new(); - element = $compile(html( - '
' + - '
' + - '
' - ))($scope); - - $scope.$apply('value = true'); - - $location.path('/bar'); - $rootScope.$digest(); - - var destroyed, inner = element.children(0); - inner.on('$destroy', function() { - destroyed = true; - }); - - $location.path('/foo'); - $rootScope.$digest(); - - $location.path('/bar'); - $rootScope.$digest(); - - $location.path('/bar'); - $rootScope.$digest(); - - expect(destroyed).toBe(true); - }); - }); });