Re: [whatwg/dom] TreeWalker::nextNode() method, loops infinite (#787)

I'm pretty sure that #667 is identical to my suggested fix. Using the algorithm in #667:
- 3.iv.a checks if it's got to the top of the tree. In this case, sibling must be null. It breaks (goes to step 3.v) which then breaks again (to 4) which returns null. This is the same as the original algorithm which just returns null in step 3.iv.a.

- 3.v checks sibling for null. This line can only be executed if temporary is null (which, without the change to 3.iv.a can't happen since it should hit the root first) or if 3.iv.c has broken. But, in the latter, sibling isn't null so this step would just continue.

- 3.vi sets node to sibling as my suggested fix does a little earlier.

So I think the difference between my suggestion and the suggestion in #667 is just stylistic. #667 doesn't seem to like early returns, whereas the original algorithm returns in the middle of loops.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/787#issuecomment-551829951

Received on Friday, 8 November 2019 13:54:02 UTC