From 123ed1f4425230aa336a7ea616064e8cdbd9dfd9 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Fri, 14 Feb 2014 12:04:00 -0800 Subject: [PATCH] Fix IE8 bug during unitless CSS props creation IE8 goes into an infinite loop if we add props to the obj we're iterating through. --- src/browser/dom/CSSProperty.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/browser/dom/CSSProperty.js b/src/browser/dom/CSSProperty.js index dcea5a3650..5f45e0895e 100644 --- a/src/browser/dom/CSSProperty.js +++ b/src/browser/dom/CSSProperty.js @@ -53,11 +53,14 @@ function prefixKey(prefix, key) { * of vendor prefixes. */ var prefixes = ['Webkit', 'ms', 'Moz', 'O']; -for (var k in isUnitlessNumber) { + +// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an +// infinite loop, because it iterates over the newly added props too. +Object.keys(isUnitlessNumber).forEach(function(prop) { prefixes.forEach(function(prefix) { - isUnitlessNumber[prefixKey(prefix, k)] = isUnitlessNumber[k]; + isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; }); -} +}); /** * Most style properties can be unset by doing .style[prop] = '' but IE8