Skip to content

Commit e487292

Browse files
committedSep 30, 2014
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 angular#7606 Closes angular#9355
1 parent 6593c23 commit e487292

File tree

2 files changed

+1
-51
lines changed

2 files changed

+1
-51
lines changed
 

‎src/ngRoute/directive/ngView.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -188,27 +188,19 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
188188
link: function(scope, $element, attr, ctrl, $transclude) {
189189
var currentScope,
190190
currentElement,
191-
previousElement,
192191
autoScrollExp = attr.autoscroll,
193192
onloadExp = attr.onload || '';
194193

195194
scope.$on('$routeChangeSuccess', update);
196195
update();
197196

198197
function cleanupLastView() {
199-
if(previousElement) {
200-
previousElement.remove();
201-
previousElement = null;
202-
}
203198
if(currentScope) {
204199
currentScope.$destroy();
205200
currentScope = null;
206201
}
207202
if(currentElement) {
208-
$animate.leave(currentElement).then(function() {
209-
previousElement = null;
210-
});
211-
previousElement = currentElement;
203+
$animate.leave(currentElement);
212204
currentElement = null;
213205
}
214206
}

‎test/ngRoute/directive/ngViewSpec.js

-42
Original file line numberDiff line numberDiff line change
@@ -844,48 +844,6 @@ describe('ngView animations', function() {
844844
}
845845
});
846846
});
847-
848-
it('should destroy the previous leave animation if a new one takes place', function() {
849-
module(function($provide) {
850-
$provide.decorator('$animate', function($delegate, $$q) {
851-
var emptyPromise = $$q.defer().promise;
852-
$delegate.leave = function() {
853-
return emptyPromise;
854-
};
855-
return $delegate;
856-
});
857-
});
858-
inject(function ($compile, $rootScope, $animate, $location) {
859-
var item;
860-
var $scope = $rootScope.$new();
861-
element = $compile(html(
862-
'<div>' +
863-
'<div ng-view></div>' +
864-
'</div>'
865-
))($scope);
866-
867-
$scope.$apply('value = true');
868-
869-
$location.path('/bar');
870-
$rootScope.$digest();
871-
872-
var destroyed, inner = element.children(0);
873-
inner.on('$destroy', function() {
874-
destroyed = true;
875-
});
876-
877-
$location.path('/foo');
878-
$rootScope.$digest();
879-
880-
$location.path('/bar');
881-
$rootScope.$digest();
882-
883-
$location.path('/bar');
884-
$rootScope.$digest();
885-
886-
expect(destroyed).toBe(true);
887-
});
888-
});
889847
});
890848

891849

0 commit comments

Comments
 (0)