1
我想了解queryselectorall的這個polyfill? Specifially這一行:這個polyfill如何爲document.queryselectorall工作?
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;
}
}
這條線是CSS-表達,填補陣列'DOC .__ qsaels' – Grundy 2014-08-31 17:46:38