NodeIterator or TreeWalker objects in JSDOM [closed]
Asked Answered
A

0

9

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)
Allative answered 6/9, 2011 at 19:1 Comment(2)
That's not DOM2, that's DOM2 traversal range. There's a difference. jsdom does not support itArtificer
Ah, thank you. I guess I'm not clear on where the spec begins and ends.Allative

© 2022 - 2024 — McMap. All rights reserved.