I'm trying to use jsdom in node.js to do a small transformation to an HTML document. When doing my client-side tests, I used the document.createTreeWalker
and document.createNodeIterator
functions, which are part of the DOM 2 specification...however, they're not apparently part of jsdom, even though its authors claim that it has full DOM1 and DOM2 compatibility. Am I missing something? Are these functions available in a document created by jsdom?
$ node
> var jsdom = require('jsdom');
> var doc = jsdom.jsdom('<div>Test</div><div>One</div><div>Two</div>');
> doc.createTreeWalker(doc)
TypeError: Object [ null ] has no method 'createTreeWalker'
at [object Context]:1:5
at Interface.<anonymous> (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream.<anonymous> (readline.js:73:12)
at ReadStream.emit (events.js:81:20)
at ReadStream._emitKey (tty_posix.js:307:10)
at ReadStream.onData (tty_posix.js:70:12)