Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
_.ready(function(){
window.collect = {
users: _('a.user'),
paraghaphs: _('#content p')
}
});var cycles = 100, newNodes = [];
var s = new Date();
while (cycles--) {
var items = document.getElementsByTagName('img'),
i = 0,
item,
klass,
idx = 0,
parent;
while (item = items[i++]) {
if (!item.yeasss && /(^| )photo($| )/.test(item.className)) {
parent = item.parentNode;
do {
if (parent.nodeName.toLowerCase() === 'div') {
newNodes[idx++] = !(item.yeasss = 1) || item;
break;
}
} while (parent = parent.parentNode);
}
}
while (idx--) {
newNodes[idx].yeasss = null;
}
}
alert(new Date() - s);
cycles = 100, newNodes = [];
s = new Date();
while (cycles--) {
var items = document.getElementsByTagName('div'),
i = 0,
item,
klass,
idx = 0,
children,
child,
h = 0;
while (item = items[i++]) {
children = item.getElementsByTagName('img');
h = 0;
while (child = children[h++]) {
if (!child.yeasss && /(^| )photo($| )/.test(child.className)) {
newNodes[idx++] = !(child.yeasss = 1) || child;
}
}
}
while (idx--) {
newNodes[idx].yeasss = null;
}
}
alert(new Date() - s);
for (child in children) {
if (children[child].yeasss != uid) {
if (last) {
children[child].yeasss = uid;
}
newNodes = children[child];
}
}
var j = 0,
item;
while (item = a[j++]) {
item++;
}
var j = -1; while (a[++j]) a[j]++;
// Получить все h1.title
var headings = document.evaluate('//h1[contains(@class, "title")]', document, null, XPathResult.ANY_TYPE, null)
var thisHeading = headings.iterateNext();
var alertText = ''
while (thisHeading) {
alertText += thisHeading.textContent + "\n";
thisHeading = headings.iterateNext();
}
alert(alertText);
Архитектура YASS. Часть 2: выборка по CSS-селектору