Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fdaf4d5

Browse files
maksimrgkalpak
authored andcommitted
fix(ngAnimate): properly handle empty jqLite collections
Previously `stripCommentsFromElement()` would return an empty Array (instead of a jqLite collection) which would cause an exception to be thrown: "element.parent not a function". This commit fixes it, by ensuring that the returned value is always a jqLite collection. Closes #14558 Closes #14559
1 parent 1c47abc commit fdaf4d5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/ngAnimate/shared.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function stripCommentsFromElement(element) {
127127
if (element instanceof jqLite) {
128128
switch (element.length) {
129129
case 0:
130-
return [];
130+
return element;
131131
break;
132132

133133
case 1:

test/ngAnimate/animateSpec.js

+13
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,19 @@ describe("animations", function() {
393393
expect(capturedAnimation).toBeFalsy();
394394
}));
395395

396+
it('should not attempt to perform an animation on an empty jqLite collection',
397+
inject(function($rootScope, $animate) {
398+
399+
element.html('');
400+
var emptyNode = jqLite(element[0].firstChild);
401+
402+
$animate.addClass(emptyNode, 'some-class');
403+
$rootScope.$digest();
404+
405+
expect(capturedAnimation).toBeFalsy();
406+
})
407+
);
408+
396409
it('should perform the leave domOperation if a text node is used',
397410
inject(function($rootScope, $animate) {
398411

0 commit comments

Comments
 (0)