Closed tilgovi closed 4 years ago
I imagine this would cause an immediate issue with a literal implementation of these steps because the first search would fail the assertion that walker.currentTreeNode
is a text node.
Yeah, none of the treewalker stuff seems to make any sense. It's created in an invalid state, advanced in ways that make no sense given the state it might be in, etc. I can't figure out what behavior it's actually trying to aim for....
It's also quite strange to use a JavaScript API to walk the tree, instead of walking the underlying spec tree structures directly. What happens if someone does window.TreeWalker = undefined
, or TreeWalker.prototype.nextNode = undefined
?
From the find a target text algorithm steps (section 2.4.3), step 13 initializes a
TreeWalker
but does not specify what theroot
node or thewhatToFind
filter should be.