[whatwg] getElementsByAttr
Dan Dorman
dan.dorman at gmail.com
Fri Jul 6 15:24:44 PDT 2007
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
that.
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?
Dan
More information about the whatwg
mailing list