@samitouri / QOS-React-2 / commits / 123ed1f442

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.

Cheng Lou committed Feb 14, 2014 at 12:04 UTC 123ed1f4425230aa336a7ea616064e8cdbd9dfd9
1 file changed +6 -3
src/browser/dom/CSSProperty.js
+6 -3
@@ -53,11 +53,14 @@ function prefixKey(prefix, key) {
53 * of vendor prefixes.
54 */
55 var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
56 -for (var k in isUnitlessNumber) {
56 +
57 +// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
58 +// infinite loop, because it iterates over the newly added props too.
59 +Object.keys(isUnitlessNumber).forEach(function(prop) {
60 prefixes.forEach(function(prefix) {
58 - isUnitlessNumber[prefixKey(prefix, k)] = isUnitlessNumber[k];
61 + isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
62 });
60 -}
63 +});
64
65 /**
66 * Most style properties can be unset by doing .style[prop] = '' but IE8