From c130bb368215a347cf153b79db0fbbf5048af174 Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Mon, 3 Oct 2022 11:02:15 -0700 Subject: [PATCH] Document scopes without selectors Incorporating changes from https://github.com/w3c/csswg-drafts/issues/7349 --- src/scope/explainer.11tydata.yaml | 2 ++ src/scope/explainer.md | 32 +++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/scope/explainer.11tydata.yaml b/src/scope/explainer.11tydata.yaml index d74b51b..707249a 100644 --- a/src/scope/explainer.11tydata.yaml +++ b/src/scope/explainer.11tydata.yaml @@ -4,6 +4,8 @@ created: 2020-12-15 changes: - time: 2021-08-24 log: Link to syntax comparison + - time: 2022-10-03 + log: Document scopes without selectors (thanks to [Dan Fabulich](https://twitter.com/dfabu)) eleventyNavigation: key: scope-explainer title: Proposal & Explainer diff --git a/src/scope/explainer.md b/src/scope/explainer.md index 0b52094..d71ef4c 100644 --- a/src/scope/explainer.md +++ b/src/scope/explainer.md @@ -356,8 +356,8 @@ but adding a lower boundary: ``` I think that's a good place to start. -In my mind, the first ("from") clause should be required, -and may not need explicit labeling. + +In my mind, the first ("from") clause may not need explicit labeling. It would accept a single (complex) selector (or selector list?): @@ -412,6 +412,34 @@ provide syntax sugar for single-file components -- automatically generating the from/to clauses -- but move the primary functionality into CSS. +Finally, we could allow `@scope` without any selector clauses, which would scope the styles to the parent of the stylesheet's owner node (or the containing tree for constructable stylesheets with no owner node). + +```html +
+ +

this is red

+
+

not red

+``` + +That would be equivalent to: + +```html +
+ +

this is red

+
+

not red

+``` + ### The (existing) `:scope` pseudo-class In most cases we can infer