[whatwg] getElementsByClassName()

Jim Ley wrote:
> On 2/3/06, Gervase Markham <gerv at mozilla.org> wrote:
>> Jim Ley wrote:
>>>  the document of course shows no use cases at all.
>> Is there some doubt that the ability to tag an arbitrary set of elements
>> and later easily get an array of those elements is a useful feature for
>> web development?
> 
> I've yet to hear of an actual reason to do so, people keep saying it
> seems useful...
> 
>> If you would like use cases, I present all of the web pages currently
>> using a JS implementation of getElementsByClassName based on
>> getElementsByTagName("*") and some manual class name inspection logic.
> 
> Yes, but they're all using it to attach events to every one of the
> class, which is why you have to look at use cases, the reason they're
> doing it is not because getElementsByClassName is missing, but because
> addEventListenerToClass or -moz-binding etc. are missing.
> 
> It's the classic mistake of looking at making the workarounds easier,
> when you should be looking at making the underlying use easier.
> 
> Jim.
> 

Hmm, i've used getElementsByTagName in the past couple of days, 
specifically to walk a table row's data cells to retrieve and write 
data. This was part of a HTML4 datagrid implimentation and the first 
time i'd found a use for said function. Having this alongside 
getElementById but missing out getElementsByClassName seems 
short-sighted to me. There may be a use we havent thought of yet, and it 
seems like a logical function to round out the family, rather than bloat.

Ric

Received on Friday, 3 February 2006 06:58:50 UTC