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

Re: [selectors api] Why two methods?

From: Martijn <martijn.martijn@gmail.com>
Date: Sun, 28 Jan 2007 00:03:35 +0100
Message-ID: <6c97b8b10701271503i77652953ie005dd38bc41c0fa@mail.gmail.com>
To: "Anne van Kesteren" <annevk@opera.com>
Cc: "David Håsäther" <hasather@gmail.com>, public-webapi@w3.org

On 1/27/07, 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.

I don't see any difference:.
document.getElementBySelector("html > p")
is the same as document.getElementListBySelector("html > p")[0]

document.getElementBySelector("html > p:not(:first-child)")
is the same as document.getElementListBySelector("html >

document.getElementBySelector("html > p:last-child")
is the same as document.getElementListBySelector("html > p:last-child")[0]

as far as I can see.

Received on Saturday, 27 January 2007 23:03:44 GMT

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