Skip to content

Commit

Permalink
fix(ngAnimate): TypeError Cannot call method 'querySelectorAll' in ca…
Browse files Browse the repository at this point in the history
…ncelChildAnimations

When element with ng-repeat has an ng-if directive and user try to remove any item from array used for ng-repeat, he gets error "TypeError Cannot call method 'querySelectorAll' of undefined". This happens because in method cancelChildAnimations of ngAnimate directive not checked value returned from extractElementNode(element) method.
Fix add a validation for result of extractElementNode(element) method.

Closes angular#6205
  • Loading branch information
Stanislav Sysoev committed Feb 19, 2014
1 parent b488bbf commit 8db5cb7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,16 +940,18 @@ angular.module('ngAnimate', ['ng'])

function cancelChildAnimations(element) {
var node = extractElementNode(element);
forEach(node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME), function(element) {
element = angular.element(element);
var data = element.data(NG_ANIMATE_STATE);
if(data && data.active) {
angular.forEach(data.active, function(operation) {
(operation.done || noop)(true);
cancelAnimations(operation.animations);
});
}
});
if (node) {
forEach(node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME), function(element) {
element = angular.element(element);
var data = element.data(NG_ANIMATE_STATE);
if(data && data.active) {
angular.forEach(data.active, function(operation) {
(operation.done || noop)(true);
cancelAnimations(operation.animations);
});
}
});
}
}

function cancelAnimations(animations) {
Expand Down

0 comments on commit 8db5cb7

Please sign in to comment.