Skip to content

Commit 5b053b1

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 angular#14558 Closes angular#14559
1 parent 81bf7ed commit 5b053b1

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
@@ -414,6 +414,19 @@ describe("animations", function() {
414414
expect(capturedAnimation).toBeFalsy();
415415
}));
416416

417+
it('should not attempt to perform an animation on an empty jqLite collection',
418+
inject(function($rootScope, $animate) {
419+
420+
element.html('');
421+
var emptyNode = jqLite(element[0].firstChild);
422+
423+
$animate.addClass(emptyNode, 'some-class');
424+
$rootScope.$digest();
425+
426+
expect(capturedAnimation).toBeFalsy();
427+
})
428+
);
429+
417430
it('should perform the leave domOperation if a text node is used',
418431
inject(function($rootScope, $animate) {
419432

0 commit comments

Comments
 (0)