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

Commit 9f48025

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 1d0ccd0 commit 9f48025

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/ngAnimate/shared.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,19 @@ describe("animations", function() {
394394
expect(capturedAnimation).toBeFalsy();
395395
}));
396396

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

0 commit comments

Comments
 (0)