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

[whatwg] getElementsByAttr

From: Sander <html5@zoid.nl>
Date: Fri, 06 Jul 2007 22:05:26 +0200
Message-ID: <468EA086.6040002@zoid.nl>

Charles McCathieNevile schreef:
> On Fri, 06 Jul 2007 21:24:25 +0200, Sander <html5 at zoid.nl> wrote:
>
>> I'd like to see a getElementsByAttr method. It would be quite similar as
>> the getElementsByClassName method but with an extra argument:
>>
>> getElementsByAttr(attribute_name, value)
>
> The W3C's WebAPI group is specifying a selectors API (the spec was 
> mostly put together by Anne van Kesteren, and now Lachy Hunt is 
> finishing it up), which allows you to do this. The longest running 
> issue is the name of the methods (hopefully we have some closure on 
> that now...) but it lets you do something like
>
> methodName("*[lang|=en]") that returns whatever matches that selector....
>
> the current editor's draft can be found at 
> http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html 
>

Aha, a CSS selector kind of filtering. That's nice as a lot of authors 
will be familiar with that type of notation.

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'd say just a selectElements method would be 
enough, but perhaps I'm missing something obvious here.

Anyway, I really hope this kind of function will be added.

cheers,
Sander
Received on Friday, 6 July 2007 13:05:26 UTC

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