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.
This commit is contained in:
Cheng Lou
2014-02-14 12:41:44 -08:00
committed by Paul O’Shannessy
parent 31bc18d39e
commit 123ed1f442
+6 -3
View File
@@ -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