fix($animate): ensure all comment nodes are removed during a leave animation

Closes #6403
This commit is contained in:
Matias Niemelä
2014-02-26 16:07:36 -05:00
parent 73daa79e91
commit f4f1f43d51
2 changed files with 22 additions and 2 deletions

View File

@@ -436,8 +436,7 @@ angular.module('ngAnimate', ['ng'])
cancelChildAnimations(element);
this.enabled(false, element);
$rootScope.$$postDigest(function() {
element = stripCommentsFromElement(element);
performAnimation('leave', 'ng-leave', element, null, null, function() {
performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
$delegate.leave(element);
}, doneCallback);
});

View File

@@ -3418,6 +3418,27 @@ describe("ngAnimate", function() {
});
});
it('should remove all element and comment nodes during leave animation',
inject(function($compile, $rootScope) {
$rootScope.items = [1,2,3,4,5];
var element = html($compile(
'<div>' +
' <div class="animated" ng-repeat-start="item in items">start</div>' +
' <div ng-repeat-end>end</div>' +
'</div>'
)($rootScope));
$rootScope.$digest();
$rootScope.items = [];
$rootScope.$digest();
expect(element.children().length).toBe(0);
}));
it('should not throw an error when only comment nodes are rendered in the animation',
inject(function($rootScope, $compile) {