- From: Emilio Cobos Álvarez via GitHub <sysbot+gh@w3.org>
- Date: Fri, 05 Apr 2024 13:12:42 +0000
- To: public-css-archive@w3.org
emilio has just created a new issue for https://github.com/w3c/csswg-drafts:
== [selectors] Should :not(foo) match the host of the shadow tree? ==
https://github.com/w3c/csswg-drafts/issues/9509 clarified that stuff like `:is(:host)` should definitely match, due to text in https://drafts.csswg.org/selectors/#data-model:
> A [featureless](https://drafts.csswg.org/selectors/#featureless) element does not match any selector at all, except those it is explicitly defined to match (and [logical combination pseudo-classes](https://drafts.csswg.org/selectors/#logical-combination-pseudo-classes) representing those selectors).
So after discussing a bit with @sesse, it wasn't super-clear to me what the expected behavior is for something like this:
```
<!doctype html>
<div id="host" style="color: blue">
<template shadowrootmode="open">
<style>:not(span) { color: green !important }</style>
What color is this text?
</template>
</div>
```
I could see arguments for both behaviors:
* On one hand, it feels very unexpected that something that doesn't contain a `:host` selector at all to match that host.
* But on the other hand, it feels weird that neither `span` nor `:not(span)` match.
My read of the spec is that `:not(span)` should _not_ match, because that selector is not "a logical combination pseudo-class representing those selectors [`:host` for simplicity]".
I think that's my preferred behavior too, because that makes it simpler to determine "can this selector match the host" (we optimize stylesheets in shadow trees to not match a lot of the rules from the host). But ultimately I could go either way I guess.
My read of the spec doesn't match @sesse, and it seems at least the spec could get a clarification of what that "representing those selectors" means. Maybe "containing those selectors", if my read is correct, or just removing that text, if @sesse's is?
cc @tabatkins @rniwa
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10179 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 5 April 2024 13:12:43 UTC