[csswg-drafts] [css-cascade-6] add a :stylesheet selector to match the current stylesheet (#7349)

faceless2 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-cascade-6] add a :stylesheet selector to match the current stylesheet ==
This is derived from both https://github.com/w3c/csswg-drafts/issues/3547 and (in particular) https://github.com/w3c/csswg-drafts/issues/6606, but I've opened a new issue as it's a more specific proposal.

Suggestion is: add a `:stylesheet` pseudo-class selector which functions like `:scope` but matches the element that declared the rule - ie the `<style>` or `<link>`element that created the stylesheet. For programatically created stylesheets, it would match nothing.

* I suspect this would be very easy to implement as the rule should already have a reference to the stylesheet that declared it.
* it would mean the functionality of the old `<style scoped>` syntax could be reproduced. This has been pretty heavily discussed in 3547, it was clearly popular, and while `@scope` is good it doesn't(*) provide a direct replacement for that functionality. `:stylesheet` would do that:

```css
<style>
@scope (* > :stylesheet) {
...
}
</style>
```

(* you could give the `<style>` an id and reference that from the `@scope` rule, so it's technically possible; just not very flexible)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7349 using your GitHub account


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

Received on Saturday, 11 June 2022 13:04:33 UTC