Skip to content

Commit f4f1f43

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

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
@@ -3418,6 +3418,27 @@ describe("ngAnimate", function() {
34183418
});
34193419
});
34203420

3421+
it('should remove all element and comment nodes during leave animation',
3422+
inject(function($compile, $rootScope) {
3423+
3424+
$rootScope.items = [1,2,3,4,5];
3425+
3426+
var element = html($compile(
3427+
'<div>' +
3428+
' <div class="animated" ng-repeat-start="item in items">start</div>' +
3429+
' <div ng-repeat-end>end</div>' +
3430+
'</div>'
3431+
)($rootScope));
3432+
3433+
$rootScope.$digest();
3434+
3435+
$rootScope.items = [];
3436+
3437+
$rootScope.$digest();
3438+
3439+
expect(element.children().length).toBe(0);
3440+
}));
3441+
34213442
it('should not throw an error when only comment nodes are rendered in the animation',
34223443
inject(function($rootScope, $compile) {
34233444

0 commit comments

Comments
 (0)