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

Re: [selectors-api] Summary of Feature Requests for v2

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 23 Sep 2009 20:37:26 -0700
Message-ID: <63df84f0909232037t5cc594fcx109cb177963a0a2c@mail.gmail.com>
To: John Resig <jeresig@gmail.com>
Cc: Lachlan Hunt <lachlan.hunt@lachy.id.au>, public-webapps <public-webapps@w3.org>
On Wed, Sep 23, 2009 at 8:17 PM, John Resig <jeresig@gmail.com> wrote:
> Quick Summary of my opinions:
> Matches Selector: Super-super useful - critical, in fact. We're not able to
> remove jQuery's selector engine until this is implemented. I'm working with
> the devs at Mozilla to get an implementation landed. Already have a test
> suite in place.

And we have a patch :) So this should be available in Firefox 3.6 I hope.

> Filtering NodeLists/StaticNodeLists, Queries on NodeLists/StaticNodeLists:
> Neither of these are useful, as is, to libraries. What is actually useful is
> the ability to run these against an array (or array-like collection) of DOM
> nodes.

Very good input!

> If I can do:
> document.querySelectorAll.call([document.getElementById("node1"),
> document.getElementById("node2")], "div > span"); then yes, this proposal is
> useful. Rarely do libraries store raw NodeLists (they need to be converted
> into an array or array-like collection first).

I think filtering can easily be done using the filter function that's
available in Firefox these days. Don't know what the implementation
situation is for other UAs. But something like

filteredArray = myArrayOfNodes.filter(function(node) { return
node.matchesSelector("some>selector"); });

For "querySelectorAll on arrays" to work we'd need some function that
can merge multiple nodelists. Once you have that you can easily use
Array.map to get what you need.

> Scoped Queries: Also critical. As it stands, in jQuery, we just punt
> whenever does a query rooted to a DOM element and fallback to the old
> selector engine.

Does the :scope selector solve things for you? Or does it not because
of selectors like "> foo, > bar", or even "foo, bar"?

/ Jonas
Received on Thursday, 24 September 2009 03:38:31 UTC

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