Skip to content

Commit 590accc

Browse files
committed
fix($animate): ensure all comment nodes are removed during a leave animation
Closes angular#6403
1 parent c914cd9 commit 590accc

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/ngAnimate/animate.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,7 @@ angular.module('ngAnimate', ['ng'])
436436
cancelChildAnimations(element);
437437
this.enabled(false, element);
438438
$rootScope.$$postDigest(function() {
439-
element = stripCommentsFromElement(element);
440-
performAnimation('leave', 'ng-leave', element, null, null, function() {
439+
performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
441440
$delegate.leave(element);
442441
}, doneCallback);
443442
});

test/ngAnimate/animateSpec.js

+21
Original file line numberDiff line numberDiff line change
@@ -3371,6 +3371,27 @@ describe("ngAnimate", function() {
33713371
});
33723372
});
33733373

3374+
it('should remove all element and comment nodes during leave animation',
3375+
inject(function($compile, $rootScope) {
3376+
3377+
$rootScope.items = [1,2,3,4,5];
3378+
3379+
var element = html($compile(
3380+
'<div>' +
3381+
' <div class="animated" ng-repeat-start="item in items">start</div>' +
3382+
' <div ng-repeat-end>end</div>' +
3383+
'</div>'
3384+
)($rootScope));
3385+
3386+
$rootScope.$digest();
3387+
3388+
$rootScope.items = [];
3389+
3390+
$rootScope.$digest();
3391+
3392+
expect(element.children().length).toBe(0);
3393+
}));
3394+
33743395
it('should not throw an error when only comment nodes are rendered in the animation',
33753396
inject(function($rootScope, $compile) {
33763397

0 commit comments

Comments
 (0)