TreeWalker nextSibling
/previousSibling
throw error when currentNode
is set to another DOM tree
#558
Labels
bug
Something isn't working
When TreeWalker is walking a DOM tree it was not initialised with it throws an error when
nextSibling
/previousSibling
are called and it reaches the (other DOM tree's) root.Although the spec doesn't explicitly allow or deny it, it's actually possible to initialize a TreeWalker instance and then use the
.currentNode
setter to change to a completely different DOM tree and then walk it.Given the following reproduction:
Running the code, this error is throw:
I
abuseuse this behaviour in one of my libraries so I can reuse the same TreeWalker instance as a performance optimisation. Works as expected in browsers andjsdom
, it's justhappy-dom
which throws.The text was updated successfully, but these errors were encountered: