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

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:05 UTC