`
yiminghe
  • 浏览: 1453305 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Ext.util.CSS IE下小问题

阅读更多

Ext.util.CSS 是直接对样式表进行操作的工具类,可以对某一类元素直接操作设置样式,而避免 dom 循环设置行内样式的效率问题。


问题:


但是他没有考虑 ie 下的 selectorText 返回为大写这一点,那么操作:

 

Ext.util.CSS.getRule(小写选择符)

 

在 IE 就什么也得不到了。


根本原因还是在于 Ext 在对样式做缓存时没有考虑 ie 下大小写因素,源代码如下:

 

rules[ssRules[j].selectorText] = ssRules[j];

 


解决:


修正为 :

 

rules[ssRules[j].selectorText.toLowerCase()] = ssRules[j];

 

另外在读取规则时也要强制转换为小写:

 

/**
    * Gets an an individual CSS rule by selector(s)
    * @param {String/Array} selector The CSS selector or an array of selectors to try. 
The first selector that is found is returned.
    * @param {Boolean} refreshCache true to refresh the internal cache if you have
 recently updated any rules or added styles dynamically
    * @return {CSSRule} The CSS rule or null if one is not found
    */
   getRule : function(selector, refreshCache){
        selector=selector.toLowerCase();

 

就 OK 了

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics