勘误
2014-03-13
这本书很值得一看。195页的editCSSRules函数貌似有点问题:
for (var j = 0; j < rules.length; j++)
if (rules[j].selectorText.toUpperCase() == selector)
for (porperty in styles)
if ( !styles.hasOwnProperty(property) ) continue;
rules[j].style[camelize(property)] = styles[property];
//if ( !styles.hasOwnProperty(property) ) continue;这个if通过检测styles是否具有property,貌似总是成立的,应该是检测styles的property属性是否具有值,即: if (!styles[property]) continue; 如果没有赋值的话继续循环,有的话,就把property属性的格式改写成驼峰式(比如font-size改写成fontSize),并赋予原本的值。