W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2005

[whatwg] getElementsBySelector etc

From: Erik Arvidsson <erik@eae.net>
Date: Mon, 19 Sep 2005 01:20:36 +0200
Message-ID: <432DF644.8060906@eae.net>
We've seen a lot of use for getElementsBySelector lately for some 
javascript implementations of bindings and behaviors [1][2]. [1] use 
Simon Willison's implementation[3] and there is also one by Dean Edward[4].

I'm not writing this just to do some link dropping. I'm writing this to 
suggest a related method that takes an element and returns true if it 
matches a CSS rule

interface GetElementsBySelector {
   NodeList getElementsBySelector(in DOMString cssSelector);

   // returns true if an element matches the given CSS selector
   boolean matchesSelector(in Element el, in DOMString cssSelector);
}

I'm not too sure about the name of this method so suggestions for a 
better name are welcome (as well as any other comment of course).

Another thing that just I'm not too sure about is whether these should 
include pseudo classes? It would be good but it makes things harder to 
implement.

In the light of the bindings and behaviors scenario it would also be 
very useful to have observers so one call tell when the matching 
changes. It might be outside the scope of web apps 1.0 though?

[1] http://bennolan.com/behaviour/
[2] http://altas.asp.net
[3] http://simon.incutio.com/archive/2003/03/25/getElementsBySelector
[4] http://dean.edwards.name/my/cssQuery/

--
erik
Received on Sunday, 18 September 2005 16:20:36 UTC

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