What's wrong with this?
YUI().use('node', function (Y)
{
var doc = Y.one('#content');
// alert(doc.getHTML());
var nodes = new Y.NodeList(doc.getElementsByTagName('h1'));
// Do something ...
});
doc.getHTML() shows the expected document with some level 1 headings. But nodes is always 'undefined: not bound to any nodes'.
Thx for your help!
'doc' is a Y.Node object, not a native DOM object, and so does not have a getElementsByTagName() method. In this case, I think you want:
var nodes = doc.all('h1');
Keep in mind that when manipulating the DOM with YUI, you are working with a facade object, a Y.Node or a Y.NodeList. Don't mix YUI method calls with native DOM method calls unless you are sure you know what you are doing.