From cf5e463abd2c23f62e9c2e6361e6c53048c8910e Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Fri, 14 Feb 2014 00:53:49 -0500 Subject: pref($animate): only trigger DOM callbacks if registered on the element being animated BREAKING CHANGE: Both the `$animate:before` and `$animate:after` DOM events must be now registered prior to the $animate operation taking place. The `$animate:close` event can be registered anytime afterwards. DOM callbacks used to fired for each and every animation operation that occurs within the $animate service provided in the ngAnimate module. This may end up slowing down an application if 100s of elements are being inserted into the page. Therefore after this change callbacks are only fired if registered on the element being animated. --- test/ngAnimate/animateSpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 41115e42..8da3d1cb 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1573,6 +1573,21 @@ describe("ngAnimate", function() { expect(steps.shift()).toEqual(['after', 'ng-enter', 'enter']); })); + it('should not fire DOM callbacks on the element being animated unless registered', + inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { + + $animate.enabled(true); + + var element = jqLite('
'); + $rootElement.append(element); + body.append($rootElement); + + $animate.addClass(element, 'class'); + $rootScope.$digest(); + + $timeout.verifyNoPendingTasks(); + })); + it("should fire a done callback when provided with no animation", inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { -- cgit v1.2.3