W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Re: [selectors-api] Scoped Queries

From: Sean Hogan <shogun70@westnet.com.au>
Date: Thu, 24 Sep 2009 14:37:12 +1000
Message-ID: <4ABAF778.4010701@westnet.com.au>
To: Jonas Sicking <jonas@sicking.cc>
CC: Lachlan Hunt <lachlan.hunt@lachy.id.au>, public-webapps <public-webapps@w3.org>, John Resig <jresig@mozilla.com>, "L. David Baron" <dbaron@mozilla.com>
Jonas Sicking wrote:
> On Wed, Sep 23, 2009 at 6:00 PM, Sean Hogan <shogun70@westnet.com.au> wrote:
>> Jonas Sicking wrote:
>>> On Wed, Sep 23, 2009 at 4:51 AM, Lachlan Hunt <lachlan.hunt@lachy.id.au>
>>> wrote:
>>>> *Scoped Queries*
>>>> http://www.w3.org/Bugs/Public/show_bug.cgi?id=5860
>>>> This has been discussed extensively in the past.  Basically, the idea is
>>>> that the selector would be evaluated in the scope of the element, in a
>>>> way
>>>> more compatible with how libraries like JQuery work.  This slightly
>>>> different from the :scope pseudo-class proposal, see bug for details.
>>> Note that what makes the ">strong, >em" selector (which apparently
>>> some libraries support) hard to support spec-wise is that that is not
>>> in fact valid CSS syntax. It's certainly possible to define behavior
>>> for it, it's pretty clear to me how it's intended to work, but it
>>> would mean specifying our own syntax.
>> It is clear how it is intended to work, but it is less powerful than a
>> :scope selector.
>> I suggest it is a low priority feature.
> But a :scope selector by itself doesn't help if the passed in selector
> to the library contains a comma separated selector like "foo, bar".
>>> However if supporting commaseparated queries is critical for libraries
>>> then I see no other choise. We'll one way or another have to specify
>>> our own syntax, though it can be heavily based on the productions in
>>> the Selector spec.
>>> / Jonas
>> Libraries already parse selector queries anyway. And some of them add
>> non-standard selectors and presumeably will continue to do so. I don't think
>> it is an issue.
> The input I've gotten from library developers is that they would love
> to not have to ship a selector engine. Apparently it would reduce the
> size of for example jQuery with about 10k which is pretty significant.
> / Jonas
They could. If something like the following is not sufficient it 
probably means they aren't happy with the native selector engine. In 
that case they will be providing their own anyway.

Element.prototype.queryScopedSelectorAll = function(selector) {
    var validSel = ":scope " + selector.replace(",", ", :scope ");
    return this.querySelectorAll(validSel);
Received on Thursday, 24 September 2009 04:38:44 UTC

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