W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2006

[whatwg] getElementsByClassName()

From: Gervase Markham <gerv@mozilla.org>
Date: Fri, 03 Feb 2006 14:54:32 +0000
Message-ID: <43E36EA8.5010603@mozilla.org>
Jim Ley wrote:
> 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.

But why implement addEventListenerToClass() when you could implement
getElementsByClassName(), which has a far more general utility? As soon
as a single non-event-listener-related application comes along, you find
you've implemented the wrong thing.

Here's a use case, then: the about:license document I just checked into
the Mozilla codebase. When the page is called with the spelling
"about:licence" instead of "about:license", I use
getElementsByClassName() to search for elements with the class
"correctme", and do a search and replace within them to correct the
spelling. However, I can't correct it everywhere as I shouldn't be
mutating legal documents. But I can do it in commentary, titles,
contents and so on.

Received on Friday, 3 February 2006 06:54:32 UTC

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