W3C home > Mailing lists > Public > www-style@w3.org > June 2007

Matching :root in Document Fragments

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Fri, 22 Jun 2007 00:31:00 +1000
Message-ID: <467A8BA4.80602@lachy.id.au>
To: www-style <www-style@w3.org>

   In relation to the Selectors API specification, a question has come 
up about whether or not the :root pseudo-class would match anything in a 
document fragment that isn't part of a document [1].

For example, given the following fragment created by a script:

var html = document.createElement("html");
// create and append body and p elements to get the following tree
// but don't append the fragment to a Document node.


The question is, would :root match the html element in that fragment, 
and thus what would the following return:

   var result = body.get(":root p");

The get() function returns descendants of the element (body in this 
case) that match the selector [2].

Selectors defines :root as:

| The :root pseudo-class represents an element that is the root of the
| document.

My assumption is that since the fragment isn't part of a document, there 
is no element that matches the :root pseudo-class, and so null would be 
returned in that example.  However, others have argued that it's unclear 
and that :root could match the html element in that example, and thus 
would return the p element.  Could the CSSWG please clarify this issue?

Thank you.

[1] http://lists.w3.org/Archives/Member/member-webapi/2007Jun/0019.html 
(member only, sorry)
[3] http://www.w3.org/TR/css3-selectors/#root-pseudo

Lachlan Hunt
Received on Thursday, 21 June 2007 14:31:17 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:29 UTC