Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document scopes without selectors #22

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/scope/explainer.11tydata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 30 additions & 2 deletions src/scope/explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?):

Expand Down Expand Up @@ -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
<div>
<style>
@scope {
p { color: red; }
}
</style>
<p>this is red</p>
</div>
<p>not red</p>
```

That would be equivalent to:

```html
<div id="foo">
<style>
@scope (#foo) {
p { color: red; }
}
</style>
<p>this is red</p>
</div>
<p>not red</p>
```

### The (existing) `:scope` pseudo-class

In most cases we can infer
Expand Down