W3C home > Mailing lists > Public > public-webapi@w3.org > May 2008

Re: [selectors-api] some doubts

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Fri, 09 May 2008 02:55:05 +0200
Message-ID: <4823A0E9.9090307@lachy.id.au>
To: João Eiras <joao.eiras@gmail.com>
Cc: Web APIs WG <public-webapi@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 9 May 2008 00:55:47 GMT