W3C home > Mailing lists > Public > public-webapi@w3.org > May 2006

Re: ACTION-87: Selectors API

From: Anne van Kesteren <annevk@opera.com>
Date: Wed, 17 May 2006 15:30:03 +0200
To: "Lachlan Hunt" <lachlan.hunt@lachy.id.au>
Cc: "Web APIs WG (public)" <public-webapi@w3.org>
Message-ID: <op.s9o6gdnq64w2qv@id-c0020.customers.swisscom-eurospot.com>

On Wed, 17 May 2006 15:19:46 +0200, Lachlan Hunt  
<lachlan.hunt@lachy.id.au> wrote:
> I like match() too because it's much shorter than  
> getElementsBySelector(),

Right... :-)

> but I think the fact that it only returns a single node is confusing and  
> that, in most cases, authors would want the whole collection, not just  
> the first match.  I think it would be better if the methods were:
> [...]

In that case you have this issue:

* match("foo")[0] (when match() would return a list)
* matchOne("foo")
* matchFirst("foo")

The shortest name should represent the most efficient method imho.

> What's wrong with using:
> var selectorMatches = document.matchAll('#bleh elm3', resolver);
> There may still be use cases for matching a sub tree, so it may be worth  
> extending the Element interface too, but all the ones I can think of can  
> be handled by simply writing a more specific selector.

Yeah, except when you get a random element back like event.target. And  
even in that case you can probably give the event some random ID in most  
cases but it's not really flexible.

Anne van Kesteren
Received on Wednesday, 17 May 2006 13:30:14 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:21 UTC