我正在尝试在node.js中使用jsdom来对HTML文档进行小的转换。在进行客户端测试时,我使用了document.createTreeWalker
和document.createNodeIterator
函数,这些函数是part of the DOM 2 specification ...但是,它们显然不是jsdom的一部分,尽管它的作者声称它具有完整的DOM1和DOM2兼容性。我错过了什么吗?这些功能是否在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)