Patient Guy wrote:
/* The line immediately below calling a NodeFilter constructor
is the one producing the error
Error: Object cannot be created in this context =
NS_ERROR_DOM_NOT_SUPPORTED_ERR
*/
var nodeFilter = new NodeFilter(collectionsFilter);
That is not supposed to work, NodeFilter as an object is only there so
that you can access the constants (e.g. NodeFilter.SHOW_ELEMENT as you
do below). You don't need any constructor function call, in the
ECMAScript binding
<http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ecma-script-binding.html>
you simply pass in a function that takes a node as an argument and
retuns a number so all you need is
var twalk = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT,
nodeFilter, false);
e.g.
document.createTreeWalker(
node,
NodeFilter.SHOW_ELEMENT,
function (node) {
// check node as needed and return one of
// FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP
},
false
)
--
Martin Honnen
http://JavaScript.FAQTs.com/