diff --git a/src/ngAnimate/shared.js b/src/ngAnimate/shared.js index a2029d211480..54d3c95412ae 100644 --- a/src/ngAnimate/shared.js +++ b/src/ngAnimate/shared.js @@ -127,7 +127,7 @@ function stripCommentsFromElement(element) { if (element instanceof jqLite) { switch (element.length) { case 0: - return []; + return element; break; case 1: diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 6bd18d456b3f..b5207a44dda8 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -394,6 +394,18 @@ describe("animations", function() { expect(capturedAnimation).toBeFalsy(); })); + it('should not attempt to perform an animation on an empty jqLite collection', + inject(function($rootScope, $animate) { + + element.html(''); + var emptyNode = jqLite(element[0].firstChild); + + $animate.addClass(emptyNode, 'some-class'); + $rootScope.$digest(); + + expect(capturedAnimation).toBeFalsy(); + })); + it('should perform the leave domOperation if a text node is used', inject(function($rootScope, $animate) {