From 7f0767acaba1ec3c8849244a604b0d1c8c376446 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Mon, 28 Oct 2013 10:43:41 -0600 Subject: fix($animate): ensure former nodes are fully cleaned up when a follow-up structural animation takes place Closes #4435 --- test/ngAnimate/animateSpec.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/ngAnimate/animateSpec.js') diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index c995cd83..bc0d3347 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1817,6 +1817,42 @@ describe("ngAnimate", function() { // expect(element.hasClass('hiding')).toBe(false); // }); // }); + it("should remove all the previous classes when the next animation is applied before a reflow", function() { + var fn, interceptedClass; + module(function($animateProvider) { + $animateProvider.register('.three', function() { + return { + move : function(element, done) { + fn = function() { + done(); + } + return function() { + interceptedClass = element.attr('class'); + } + } + } + }); + }); + inject(function($compile, $rootScope, $animate, $timeout) { + var parent = html($compile('
')($rootScope)); + var one = $compile('')($rootScope); + var two = $compile('')($rootScope); + var three = $compile('')($rootScope); + + parent.append(one); + parent.append(two); + parent.append(three); + + $animate.move(three, null, two); + $rootScope.$digest(); + + $animate.move(three, null, one); + $rootScope.$digest(); + + //this means that the former animation was cleaned up before the new one starts + expect(interceptedClass.indexOf('ng-animate') >= 0).toBe(false); + }); + }); it("should provide the correct CSS class to the addClass and removeClass callbacks within a JS animation", function() { module(function($animateProvider) { -- cgit v1.2.3