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

Re: [selectors api] Why two methods?

From: David Håsäther <hasather@gmail.com>
Date: Thu, 25 Jan 2007 21:04:52 +0100
Message-ID: <45B90D64.3000007@gmail.com>
To: Anne van Kesteren <annevk@opera.com>
CC: public-webapi@w3.org

On 2007-01-25 20:53, Anne van Kesteren wrote:
> On Thu, 25 Jan 2007 14:48:35 -0500, David Håsäther <hasather@gmail.com> 
> wrote:
>> What I mean is, why does grabbing the first node deserve its own 
>> method? Is that really a common thing to do, grabbing the first node? 
>> More common than grabbing the second or last node for instance?
> 
> Do you have a concrete example? Say that in the following document we 
> want to get one of the <p> elements:
> 
>  <html>
>   <p/>
>   <p/>
>   <p/>
>  </html>
> 
> We'd do this as follows:
> 
>  1. document.getElementBySelector("html > p")
>  2. document.getElementBySelector("html > p:not(:first-child)")
>  3. document.getElementBySelector("html > p:last-child")
> 
> (Or using an equivalent group of selectors.)

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.

-- 
David Håsäther
Received on Thursday, 25 January 2007 20:05:05 GMT

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