WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
589 stars 42 forks source link

Initializing the `TreeWalker` #73

Closed tilgovi closed 4 years ago

tilgovi commented 4 years ago

From the find a target text algorithm steps (section 2.4.3), step 13 initializes a TreeWalker but does not specify what the root node or the whatToFind filter should be.

tilgovi commented 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.

bzbarsky commented 4 years ago

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....

domenic commented 4 years ago

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?