From a2175850b4dc3ad4e2cbef4231ca1ebf26349f95 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Mon, 15 Apr 2013 17:22:34 +1200 Subject: [PATCH] fix($animator): Avoid $window.getComputedStyle on non-element nodes It throws an exception at least in some versions of FF, and is declared as taking only an Element and not an arbitrary Node in the W3C spec. One place where this can happen easily is with ng-view if the template contains more than just a single top-level node (even just a trailing newline can trigger the problem). Also short-circuit the case where getComputedStyle doesn't return anything. --- src/ng/animator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ng/animator.js b/src/ng/animator.js index 7f0f7b7a8d1b..a24d781cf45a 100644 --- a/src/ng/animator.js +++ b/src/ng/animator.js @@ -280,7 +280,9 @@ var $AnimatorProvider = function() { var duration = 0; //we want all the styles defined before and after forEach(element, function(element) { - var globalStyles = $window.getComputedStyle(element) || {}; + if (element.nodeType !== 1 /* ELEMENT_NODE */) return; + var globalStyles = $window.getComputedStyle(element); + if (!globalStyles) return; duration = Math.max( parseFloat(globalStyles[w3cTransitionProp + durationKey]) || parseFloat(globalStyles[vendorTransitionProp + durationKey]) ||