[whatwg] getElementsByAttr

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