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:
committed by
Georgios Kalpakas
parent
1c47abc462
commit
fdaf4d5e27
@@ -127,7 +127,7 @@ function stripCommentsFromElement(element) {
|
||||
if (element instanceof jqLite) {
|
||||
switch (element.length) {
|
||||
case 0:
|
||||
return [];
|
||||
return element;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user