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

[whatwg] getElementsByAttr

From: Dan Dorman <dan.dorman@gmail.com>
Date: Fri, 6 Jul 2007 16:24:44 -0600
Message-ID: <317245a10707061524t31f72b95y7952d05bbf22f848@mail.gmail.com>
On 7/6/07, Sander <html5 at zoid.nl> wrote:
> But there neither are singular versions of getElementsByTagName and
> getElementsClassName.

Yeah, and that's always sort of irked me.  If I know ahead of time I
want a single element, it's just a waste of time to dereference an
array element--granted, a rather trivial waste of time.  In fact, it
could be useful to enforce retrieval of a single element, for
performance reasons if nothing else.

I concede a conceit, though:  I think accessing selectElements()[0]
every time I want a single time is ugly.

> I'd prefer an optional extra argument.

Ugh ... I'd rather have just the one method and use
selectElements()[0] than have an optional parameter for something like

In all honesty, I'd be okay with just selectElements, plural.  I can
live with [0] notation.  But I would appreciate having the option.

I'm curious, Sander:  what is the objection to having both?

Received on Friday, 6 July 2007 15:24:44 UTC

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