W3C home > Mailing lists > Public > public-webapi@w3.org > January 2007

Re: Proposal: getElementsBySelector()

From: Maciej Stachowiak <mjs@apple.com>
Date: Sun, 28 Jan 2007 14:41:57 -0800
Message-Id: <F4B5476F-65FD-4CD0-8CB3-AF1CAD9B2855@apple.com>
Cc: "Web API WG (public)" <public-webapi@w3.org>
To: Anne van Kesteren <annevk@opera.com>

On Jan 28, 2007, at 12:11 AM, Anne van Kesteren wrote:

> Given the input from Björn I suppose there's no real need for a  
> method that returns a single element node (assuming implementations  
> make that optimization). Given that, I propose we rename .getAll()  
> to .getElementsBySelector() and drop .get() (on both Document and  
> Element).

Even with Björn's suggestion, the plural version still allocates and  
destroys the collection object that you don't need if you are getting  
a single version. Also it's more awkward to use in the case where you  
want a single item. I admit though that if the name ends up being  
longer than getElementById as currently proposed, it's less likely  
authors would use it in place gEBI.


> One advantage is that it's consistent with the naming people  
> already use for custom written functions that have this  
> functionality. In theory it's also not harder to type  
> than .getElementsByTagName(). The only thing that makes it differ  
> from the other getElementsBy* method(s) is that it doesn't return a  
> live NodeList. I don't see that as a major problem.
> If there are no strong objections I'll implement this in the  
> specification.
> -- 
> Anne van Kesteren
> <http://annevankesteren.nl/>
> <http://www.opera.com/>
Received on Sunday, 28 January 2007 22:42:30 UTC

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