Skip to content

Commit

Permalink
Merge pull request #22 from dfabulich/patch-1
Browse files Browse the repository at this point in the history
Document scopes without selectors
  • Loading branch information
mirisuzanne authored Oct 3, 2022
2 parents 8dcce31 + c130bb3 commit 7d09eac
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
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

0 comments on commit 7d09eac

Please sign in to comment.