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 a9fcb0d commit 34e9956
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,14 +868,16 @@ 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) {
cancelAnimations(data.animations);
cleanup(element);
}
});
if (node) {
forEach(node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME), function(element) {
element = angular.element(element);
var data = element.data(NG_ANIMATE_STATE);
if(data) {
cancelAnimations(data.animations);
cleanup(element);
}
});
}
}

function cancelAnimations(animations) {
Expand Down Expand Up @@ -1284,7 +1286,7 @@ angular.module('ngAnimate', ['ng'])
event.stopPropagation();
var ev = event.originalEvent || event;
var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();

/* Firefox (or possibly just Gecko) likes to not round values up
* when a ms measurement is used for the animation */
var elapsedTime = parseFloat(ev.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES));
Expand Down

0 comments on commit 34e9956

Please sign in to comment.