我想了解 queryselectorall 的这个polyfill?特别是这一行:
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}";
https://gist.github.com/connrs/2724353
if (!document.querySelectorAll) {
document.querySelectorAll = function(selector) {
var doc = document,
head = doc.documentElement.firstChild,
styleTag = doc.createElement('STYLE');
head.appendChild(styleTag);
doc.__qsaels = [];
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}";
window.scrollBy(0, 0);
return doc.__qsaels;
}
}
它正在滥用expression“特征”CSS 的。计算样式时x
属性(发生在由scrollBy(0, 0)
),Internet Explorer 将为所有与选择器匹配的元素执行此代码片段。
CSS表达式被官方鄙视从 IE 8 开始...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)