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.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
Received on Monday, 3 December 2012 12:34:02 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:50 UTC