六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 74|回复: 0

Ext.util.CSS IE下小问题

[复制链接]

升级  12%

172

主题

172

主题

172

主题

进士

Rank: 4

积分
560
 楼主| 发表于 2013-1-29 07:30:24 | 显示全部楼层 |阅读模式
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 了
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表