W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: QSA, the problem with ":scope", and naming

From: Sean Hogan <shogun70@westnet.com.au>
Date: Thu, 20 Oct 2011 19:14:23 +1100
Message-ID: <4E9FD85F.2030501@westnet.com.au>
To: Jonas Sicking <jonas@sicking.cc>
CC: Alex Russell <slightlyoff@google.com>, Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>, John Resig <jeresig@gmail.com>, Paul Irish <paulirish@google.com>, Lachlan Hunt <lachlan.hunt@lachy.id.au>
On 20/10/11 1:07 PM, Jonas Sicking wrote:
> On Tue, Oct 18, 2011 at 9:42 AM, Alex Russell<slightlyoff@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.

Received on Thursday, 20 October 2011 08:14:56 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:36 UTC