[dom] Behaviour for pointerBeforeReferenceNode when all nodes do not pass filtration (#87)

Traverse algo doesn't fit to Firefox/Chrome behaviour when we skip all nodes and try invoke NodeIterator.nextNode(). Per algo true should be change to false, but this browsers still keep true.

<script>

 var iterator = document.createNodeIterator(document, 0);
 alert(iterator.pointerBeforeReferenceNode); // true
 iterator.nextNode();
 alert(iterator.pointerBeforeReferenceNode); // true

</script>

Others edge case may by interesting, like removing referenceNode where some other node must be as referenceNode (even if not acceptable by filter), so  NodeIterator.nextNode()/NodeIterator.previousNode() should only change pointerBeforeReferenceNode or not?

 I don't know what Edge does, but IE11  still doesn't support pointerBeforeReferenceNode and referenceNode attributes.

Of course browsers can follow with these new guidelines if it's not compatibility problem and bring some simplification, or just fix this algo to fit actual browsers behaviour.

And a few comments on this algorithm (all for 3.1 step):
- "If direction..." direction is passing argument, then can be treat as variable 
- iterator collection was defined so use reference. BTW, it's collection (rooted at root, whose filter matches any node), but for iterator sense root should not be included to this collection (as first element)?
- having three /if/ conditions writing in one line (separate by dot) is quite readable, especially when first cooperate with second, and third is opposite to first. Something like we have here http://www.w3.org/TR/dom/#concept-nodeiterator-traverse is better.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/87

Received on Thursday, 8 October 2015 04:06:35 UTC