Re: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Tab Atkins Jr.
On Sun, Jul 28, 2013 at 7:28 PM, Francois REMY wrote: > Cool to see my CSS Filter thing seems the less controversial part of the mix > :-) > >> > - a new 'iterateBackwards' boolean field on TreeWalker/NodeIterator >> > that would make any ES iterator call previousNode() instead of >> > nextNode()

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Francois REMY
Cool to see my CSS Filter thing seems the less controversial part of the mix :-) > > - a new 'iterateBackwards' boolean field on TreeWalker/NodeIterator > > that would make any ES iterator call previousNode() instead of > > nextNode() when computing the next iteration (to make navigation > > po

Re: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Tab Atkins Jr.
On Sun, Jul 28, 2013 at 11:02 AM, François REMY wrote: > So, let's sum this up. The proposed changes are: > > - a new overload of createTreeWalker/createNodeIterator whose second argument > can be a string representing a CSS selector, with the other arguments now > being optional (not forced to

Re: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Anne van Kesteren
On Sun, Jul 28, 2013 at 12:19 PM, François REMY wrote: > How do you write that using WebIDL? It there an attribute for that? It's an open issue: https://www.w3.org/Bugs/Public/show_bug.cgi?id=17648 (Temporary) IDL constraints don't affect API design though. -- http://annevankesteren.nl/

Re: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Brendan Eich
Domenic Denicola wrote: `.iterator()` is a nonstandard Mozilla-ism; Rather, a temporary state while we were arguing about ES6 and waiting for symbols to be specified (still waiting). It's not a permanent addition. /be

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread François REMY
> `.iterator()` is a nonstandard Mozilla-ism; > the spec calls for a field named by the > well-known unique symbol `@@iterator`. How do you write that using WebIDL? It there an attribute for that?

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Domenic Denicola
From: François REMY [mailto:francois.remy@outlook.com] > If I'm not mistaken, all it takes for this to work is to add an .iterator() > function on the TreeWalker/NodeIterator interface `.iterator()` is a nonstandard Mozilla-ism; the spec calls for a field named by the well-known unique sym

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread François REMY
> I hate TreeWalker because it's an iterator but not an ES Iterator. > DOM is broken, legacy cruft, etc. As far as I know, an iterator can only go forward, not backward (while a tree walker can). But I agree 90% of the use cases map to a forward navigation and it would be nice to support for-of

Re: [DOM4] Short and Efficent DOM Traversal

2013-07-28 Thread Tab Atkins Jr.
On Sat, Jul 27, 2013 at 9:49 PM, François REMY wrote: > Is there any reason everybody hate TreeWalker? I hate TreeWalker because it's an iterator but not an ES Iterator. DOM is broken, legacy cruft, etc. I'm fine with something that exposes TreeWalker's abilities to start from a given node, but

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-27 Thread François REMY
> I like the idea of being able to get lazy iterators and treewalkers. > And that are driven by selectors. But I think creating a new feature > rather than trying to retrofit existing ones will be more successful. Why? I need *exactly* the behavior the TreeWalker is offering me now: ie a lazy

Re: [DOM4] Short and Efficent DOM Traversal

2013-07-27 Thread Jonas Sicking
On Jul 27, 2013 6:55 PM, "François REMY" wrote: > > TL/DR: CSS Selectors represent the most commonly used way to perform search in the DOM. But, until now, you’ve to choose between using CSS (querySelectorAll) or doing incremental search (createTreeWalker). I think we should try to fix that. > > T

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-27 Thread François REMY
> Both of these seem very like the ES6 > iterator interface. Can you just use > that instead of minting a new iterable/ > iterator interface? Again, that doesn't solve my TreeWalker use case :-/

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-27 Thread François REMY
> From: o...@chromium.org > > An alternate proposal: > http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2013-July/040264.html. > var iterator = document.querySelectorAll("abc").asIterator(); You make the assumption I want to walk in the forward direction and do not want to start from a spec

RE: [DOM4] Short and Efficent DOM Traversal

2013-07-27 Thread Domenic Denicola
Both of these seem very like the ES6 iterator interface. Can you just use that instead of minting a new iterable/iterator interface, viz. `.iterator()`/`.next()` or `.nextNode()`? The resulting code would be ```js var tw = document.createTreeWalker(document.body, "ul.menu > li"); for (var node

Re: [DOM4] Short and Efficent DOM Traversal

2013-07-27 Thread Ojan Vafai
An alternate proposal: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2013-July/040264.html. What I like about my proposal is that it can be generalized to anything that returns a Sequence and also is just less awkward than the TreeWalker/NodeIterator interfaces. On Sat, Jul 27, 2013 at 6:33