[Bug 18540] Proposal for a new acceptNode() return value for TreeWalker.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=18540

Jonas Sicking <jonas@sicking.cc> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jonas@sicking.cc

--- Comment #3 from Jonas Sicking <jonas@sicking.cc> ---
Note that this would be a pretty different implementation-wise (and to some
extent behavior-wise) from he current filters.

The current filters are implemented by calling the filter function for each
node as we scan the tree trying to figure out which node to return. Once we
have found a node we set the currentNode and return it. No state is used during
the scanning and no state is retained from the scanning. Next time we need to
scan for a new node to walk to, the only input into that algorithm is the
currentNode that is used as a starting point for the scanning.

In order to implement this new proposed value we would need to either remember
the fact that the current node returned FILTER_NO_CHILDREN. Or we would need to
re-test the currentNode when we start a new scan.

Put it another way. How would you expect the following to behave:

DOM:
<html>
  <body>
    <div>
      text here
    </div>
  </body>
</html>


JS:
walker = document.createTreeWalker(document.documentElement, SHOW_ELEMENT,
function(node) {
  if (node.dataset.hideChildren)
    return FILTER_NO_CHILDREN;
  return FILTER_ACCEPT;
});

walker.firstChild();
assert(walker.currentNode == document.body); // true
document.body.dataset.hideChildren = "true";
walker.nextNode();

What is walker.currentNode at this point?

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 20 February 2013 23:42:28 UTC