W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2007

[whatwg] getElementsByAttr

From: Dan Dorman <dan.dorman@gmail.com>
Date: Fri, 6 Jul 2007 14:47:12 -0600
Message-ID: <317245a10707061347u51b1041dy76dae02bad400685@mail.gmail.com>
On 7/6/07, Sander <html5 at zoid.nl> wrote:
> I haven't read the whole draft yet so maybe it's in there, but can you,
> or anyone else, explain why there is both a selectElement and a
> selectAllElements method?

I'm no authority, but:

If you know you're after one element, you get to deal with it directly
rather than first referencing the only contents of a single-element
array.  That's not a big deal, I suppose, but a some benefits are
reduced and more readable code (i.e., reading through the code would
make it obvious that only a single element was desired in any given
case).  Also, it sort of provides a correlation with getElementById,
and while I find the symmetry somewhat appealing, I'm not sure if that
motivated anybody's thinking.

Received on Friday, 6 July 2007 13:47:12 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:57 UTC