W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2012

Re: [selectors-api] Matching of :scope in document.querySelector(All)

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Mon, 03 Dec 2012 13:33:34 +0100
Message-ID: <50BC9C1E.1020004@lachy.id.au>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: public-webapps@w3.org
On 2012-11-30 03:01, Boris Zbarsky wrote:
> When implementing :scope support, I discovered that as things stand this
> call:
> 
>   document.querySelector(":scope")
> 
> is specified to return null.  In particular
> http://dev.w3.org/2006/webapi/selectors-api2/#queryselector step 1 calls
> http://dev.w3.org/2006/webapi/selectors-api2/#determine-contextual-reference-nodes
> which returns an empty set.  Then this empty set is passed as an
> explicit contextual reference set to selector matching in
> http://dev.w3.org/2006/webapi/selectors-api2/#evaluate-a-selector so
> that :scope doesn't match anything.
> 
> Is this intentional?

I believe the spec was written the way it was to deal with the case
where an explicitly empty set of reference nodes was given for find()
and findAll().  So it seems the current spec ended up treating these in
the same way by matching nothing:

document.querySelector(":scope")
document.findAll(":scope")

document.findAll(":scope", null)
document.findAll(":scope", [])

> I would have expected the above call to return the documentElement,
> which is what :scope would match in a non-scoped stylesheet...

I can change the spec to make the first 2 examples above match
documentElement, but keep the latter two with explicit refNodes
parameters matching nothing.

-- 
Lachlan Hunt
http://lachy.id.au/
http://www.opera.com/
Received on Monday, 3 December 2012 12:34:02 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:56 GMT