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.

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

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:36 UTC