Re: [selectors-api] some doubts

João Eiras wrote:
> 1) How do we deal with node.querySelectorAll(">foo") ?
>  should this be considered a valid selector and return children of the 
> context node with nodeName equal foo ?
>  This is a valid use case, and widely used and supported by existing 
> libraries.

It's an invalid selector, but we're trying to find a solution to cover 
the use case.  There has been some recent discussion about this.  For 
more info about the current status, see these posts.

http://lists.w3.org/Archives/Public/public-webapi/2008May/0057.html
http://lists.w3.org/Archives/Public/public-webapi/2008May/0058.html

> 2) How should following pseudo-classes be handled?
>  :hover -> make this use case clear. Should hovered element be matched, 
> or the class ignored ?

It will match, but since the NodeList returned is static, the list won't 
change dynamically as the user moves the cursor around.

>  :root -> should node.querySelectorAll(":root ...") jump to the document 
> root and use the entire document as context ?

As currently defined, all selectors are evaluated against the element in 
the context of the entire document.  So, yes, ":root ..." will match 
appropriate elements if they are contained within the document.  If it's 
a disconnected subtree or document fragment, there is no root element 
that matches :root, and so it won't match.

> 3) How should pseudo-elements be handled ?
>  ::first-line
>  ::first-letter
>  ::selection
>  ::before
>  ::after pseudo-elements
>  none of these elements are visible to the DOM, and ::selection contains 
> a too complex data structure which cannot be represented with a NodeList.

Pesudo-elements won't match anything. There's a note in the spec about 
that that says the following:

"Authors are advised that while the use of pseudo-elements in selectors 
is permitted, they will not match any elements in the document, and thus 
would not result in any elements being returned. Therefore, authors 
should avoid the use of pseudo-elements in selectors that are passed to 
the methods defined in this specification. "

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

Received on Friday, 9 May 2008 00:55:46 UTC