Re: ACTION-87: Selectors API

On Sat, 25 Feb 2006, Anne van Kesteren wrote:
> 
> During the F2F I got an action assigned to me to draft something up for 
> getElementsBySelector(). Basically a method that would take a 
> selector[1] as argument and return a (static) list of elements. In the 
> current draft (attached) there is also an optional second argument that 
> takes an XPathNSResolver as argument. Might be a bit funny to see things 
> from the XPath API being reused in the one for Selectors, but it seemed 
> like the best and easiest solution.

Comments on the draft:

* It makes no sense for the UA to implement an interface. Objects that the 
UA exposes implement interfaces, not UAs.

* The UA doesn't need to expose an object that implements the NSResolver, 
only the author does.

* Having an interface doesn't imply behaviour -- e.g. NodeList doesn't 
imply that NodeList is live. You can have an object that implemnets 
NodeList and is not live.

* IMHO getElementsBySelector() should return a live list, just like 
getElementsByTagName.

* I would recommend against supporting namespaces in the first version, 
for simplicity.

* I would recommend having getElementsBySelector and 
getElementsBySelectorNS if you wanted to support both, rather than using 
optional arguments. Some languages don't support method overloading on 
argument signatures and would need different numbers of arguments anyway.

* There is no actual conformance criteria for what should happen when the 
getElementsBySelector method is invoked (the spec says "returns" not 
"must, when invoked, return").

* The spec doesn't say _how_ to resolve the namespaces using the 
nsresolver argument.

* IMHO the argument to getElementsBySelector should be a "group of 
selectors" not a "selector" (using Selectors terminology).

* IMHO the method should not raise an exception when the selector contains 
a pseudo-element. It should would return an empty list.

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Saturday, 25 February 2006 23:56:44 UTC