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

Re: [selectors api] Why two methods?

From: Simon Pieters <zcorpan@gmail.com>
Date: Sun, 28 Jan 2007 00:17:53 +0100
To: "Anne van Kesteren" <annevk@opera.com>, David Håsäther <hasather@gmail.com>
Cc: public-webapi@w3.org
Message-ID: <op.tmt5n3pe7a8kvn@hp-a0a83fcd39d2>

On Sat, 27 Jan 2007 23:54:33 +0100, Anne van Kesteren <annevk@opera.com>  
wrote:

>
> On Thu, 25 Jan 2007 15:04:52 -0500, David Håsäther <hasather@gmail.com>  
> wrote:
>> Yes, but grabbing the first node has its own method. Grabbing the  
>> second or last does not. What I don't understand is _why_ there is a  
>> special method for grabbing the first node? I just don't think that is  
>> a common thing to do, and as Jim said, those nodes usually have an id.
>
> It's not about getting the first node, as demonstrated. It's about  
> getting a single node.

So what are the use-cases for getting a single node?

Let's see.

Get the root element? Nope, there's document.documentElement for that.

Get the HTML body element? Nope, there's document.body for that.

Get a form control in HTML? Nope, there's document.forms[0].foo for that,  
or if the form controls happens to have an id then getElementById() can be  
used.

I can't come up with other common use-cases, but of course this was only  
off the top of my head; if there are sensible use-cases and the  
performance differences are worth mentioning then it might be better to  
keep the method. But for the use-cases I could come up with for now there  
are other methods that already work and are pretty much as convenient to  
use.

Regards,
-- 
Simon Pieters
Received on Saturday, 27 January 2007 23:18:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:56 GMT