On 20/10/11 1:07 PM, Jonas Sicking wrote:
On Tue, Oct 18, 2011 at 9:42 AM, Alex Russell<slightly...@google.com> wrote:
Lachlan and I have been having an...um...*spirited* twitter discussion
regarding querySelectorAll, the (deceased?) queryScopedSelectorAll,
and ":scope". He asked me to continue here, so I'll try to keep it
short:
The rooted forms of "querySelector" and "querySelectorAll" are mis-designed.
I'd like to instead propose that we
shorten all of this up and kill both stones by introducing a new API
pair, "find" and "findAll", that are rooted as JS devs expect. The
above becomes:
element.findAll("> div> .thinger");
I like the general idea here.
I think appropriate optimizations as well as extensible functions
should be out-of-scope for this thread. They are both big subjects on
their own and we're approaching 50 emails in this thread.
If find / findAll are added to the spec there should also be an
equivalent of matchesSelector that handles implicitly scoped selector,
e.g. "> div > .thinger". To aid discussion I will call this matches(),
but I don't think it is a good final choice.
The primary use-case for matchesSelector() has been event-delegation,
and this is the same for matches(). More specifically, consider the
following scenario:
jQuery adds a new event registration method that uses event delegation
to mimic the behavior of:
$(elem).find("> div > .thinger").bind(eventType, fn);
The new method is called proxybind(), and the equivalent of the above is:
$(elem).proxybind("> div > .thinger", eventType, fn);
The event handling for proxybind() would invoke matches("> div >
.thinger", [elem]) on elements between the event target and elem to find
matching elements.
Sean