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
This commit is contained in:
Maksim Ryzhikov
2016-05-04 19:18:00 +03:00
committed by Georgios Kalpakas
parent 1c47abc462
commit fdaf4d5e27
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ function stripCommentsFromElement(element) {
if (element instanceof jqLite) {
switch (element.length) {
case 0:
return [];
return element;
break;
case 1:
+13
View File
@@ -393,6 +393,19 @@ 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) {