yui/yui3 — pull request #879 by ziggyism (2013-06-17 22:39:15+00:00)
Title: Update selector-css2.js

Corrected YUI's buggy implementation of getElementsByTagName (useful on agents who don't support getEBTN on document fragments).

var doc, find;

// YUI's old implementation wrapped in a "find" function
find = function(root, tagName) {
var nodes = [], child = root.firstChild;
while (child) {
// only collect HTMLElements
// match tag to supplement missing getElementsByTagName
if (child.tagName && (tagName === '*' || child.tagName === tagName)) {
nodes.push(child);
}
child = child.nextSibling || child.firstChild;
}
return nodes;
};

doc = window.document;

console.log(doc.getElementsByTagName("*").length);
console.log(find(doc, "*").length);

As you can see, a large number of nodes are missed in the buggy version.