Re: [csswg-drafts] [css-scoping] [selectors] :scope and DocumentFragment / ShadowRoot (#7261)

OK, I may have been too quick to declare a ninja edit. [But hey, I got your attention :-)]. I did see the https://github.com/w3c/csswg-drafts/issues/6399 reference, but I couldn't immediately understand why some fix related to `:has()` would also (seemingly) change whether or not `:scope` _in general_ could match non-elements (subject or not).

> Rune's reading [...] was just wrong.

OK, but to be fair, Emilio and me (I remember looking at the spec at the time as well) _also_ read the old spec as ":scope matches ELEMENTS ONLY". But whatever, let's move on:

> So following the specs as they are written today, document.querySelector(":scope > *") should return the html element, just as myshadowroot.querySelector(":scope > *") returns all the root nodes in the shadow tree.

Yeah, that behavior makes sense. It's not what browsers implement though.

But this is good, it resolves another question I had about `@scope {}` (without a prelude) from a constructed stylesheet in a shadow tree. If `:scope` could _only_ match real elements, then `@scope { :scope > div {} }` could never match anything, but with the "virtual scoping root" it could be allowed to match the shadow root.

Closing the issue again, hopefully we can change implementations rather than changing the spec.


-- 
GitHub Notification of comment by andruud
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7261#issuecomment-1433606314 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 16 February 2023 19:30:51 UTC