W3C home > Mailing lists > Public > www-style@w3.org > September 2014

Re: Behavior of matches() and closest() with :scope()

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Wed, 24 Sep 2014 10:09:27 -0400
Message-ID: <5422D097.5010108@mit.edu>
To: Sean Hogan <shogun70@westnet.com.au>, "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Anne van Kesteren <annevk@annevk.nl>, "www-style@w3.org" <www-style@w3.org>, "www-dom@w3.org" <www-dom@w3.org>, David Håsäther <hasather@gmail.com>
On 9/24/14, 2:28 AM, Sean Hogan wrote:
> Has any browser implemented :scope in CSS? Does it still mean scope there?

Gecko has.

It's matched in the following ways in Gecko right now (at least in a 
nightly with various default-disabled stuff enabled; item 2 below is not 
enabled by default yet and closest() is not supported in a shipped 
release yet):

1)  When matching selectors from a scoped stylesheet, :scope matches the 
parent of the <style scoped>.

2)  When matching selectors for shadow DOM <content>, :scope matches the 
shadow host.

3)  When doing querySelector/querySelectorAll, :scope matches the node 
the call happened on.

4)  When doing closest() or matches(), :scope matches the node the call 
happened on.

5)  In all other cases, when matching an element E, :scope will match 
E.ownerDocument.documentElement.

I guess only cases 1 and 5 are really "CSS" from your point of view, right?

Note that we do not implement queryAll yet, so haven't had to really 
look into what happens there.

I can't speak for other UAs.

-Boris
Received on Wednesday, 24 September 2014 14:10:03 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:46 UTC