From b9557b0a86206d938a738ea470736d011dff7e1a Mon Sep 17 00:00:00 2001 From: Grzegorz Lachowski Date: Mon, 21 Oct 2013 18:50:48 +0200 Subject: fix(ngAnimate): fix cancelChildAnimations throwing exception fix ngAnimate throwing exception in cancelChildAnimations on deletion of element (ngAnimate's leave decorator) of repeated element when using ng-include on this element. Closes #4548 --- src/ngAnimate/animate.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 88a72073..a58e02d2 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -199,6 +199,7 @@ angular.module('ngAnimate', ['ng']) var forEach = angular.forEach; var selectors = $animateProvider.$$selectors; + var ELEMENT_NODE = 1; var NG_ANIMATE_STATE = '$$ngAnimateState'; var NG_ANIMATE_CLASS_NAME = 'ng-animate'; var rootAnimateState = {running:true}; @@ -583,7 +584,12 @@ angular.module('ngAnimate', ['ng']) } function cancelChildAnimations(element) { - angular.forEach(element[0].querySelectorAll('.' + NG_ANIMATE_CLASS_NAME), function(element) { + var node = element[0]; + if(node.nodeType != ELEMENT_NODE) { + return; + } + + angular.forEach(node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME), function(element) { element = angular.element(element); var data = element.data(NG_ANIMATE_STATE); if(data) { @@ -639,8 +645,7 @@ angular.module('ngAnimate', ['ng']) var durationKey = 'Duration', propertyKey = 'Property', delayKey = 'Delay', - animationIterationCountKey = 'IterationCount', - ELEMENT_NODE = 1; + animationIterationCountKey = 'IterationCount'; var NG_ANIMATE_PARENT_KEY = '$ngAnimateKey'; var lookupCache = {}; -- cgit v1.2.3