-
Notifications
You must be signed in to change notification settings - Fork 218
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
Add proposal for @sheet to enable multiple stylesheets per file #931
base: main
Are you sure you want to change the base?
Conversation
AtSheet/explainer.md
Outdated
[SameObject] readonly attribute StyleSheetList nestedStyleSheets; | ||
}; | ||
``` | ||
*Open issue: The name `nestedStyleSheets` is up for discussion* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe namedStyleSheets
?
Co-authored-by: Dan Clark <[email protected]>
|
||
```html | ||
<style> | ||
/* The following two imports should only make a single network request. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these are missing indentation
readonly attribute DOMString? name; | ||
}; | ||
``` | ||
*Open issue: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be here?
1. Whether rules are applied automatically for `@sheet` definitions, or whether they need to be imported to apply. The CSS Working Group did not have a consensus. | ||
2. Fragment-only identifiers (without a URL) should allow inline `@sheet` references on the same document to be included globally (even within shadow roots). This wasn't brought up in the CSSWG discussions at all, but is important for DSD without requiring an external file (to avoid FOUC). | ||
3. Behavior of `@import` - should `@import` be possible within `@sheet` at all, should it be allowed if it's the first/only statement, or should it be blocked? There was discussion of this in the CSSWG, but no conclusion was reached. This was briefly discussed in this CSSWG conversation: https://lists.w3.org/Archives/Public/www-style/2023Apr/0004.html | ||
4. What happens with multiple `@sheet` definitions with the same identifier? First-definition wins, or do they get merged like `@layer`? Again, this was brought up in the CSSWG but not resolved. Note that it's possible to have a "Flash of other-styled content" if it's last-defintion-wins, as the first definition may apply, then a later definition from an external CSS file may override it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we link to where this was brought up in the CSSWG?
<span>I'm in the light DOM</span> | ||
``` | ||
6. The name `nestedStyleSheets` is up for discussion. | ||
7. Should we add `name` to the `StyleSheet` interface or overload the existing `title` attribute instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space before "overload"
|
||
sheet.css: | ||
|
||
```html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```html | |
```css |
sheet.css: | ||
|
||
```html | ||
@sheet foo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CSS here doesn't seem to be valid. Was it meant to be this?
@sheet foo {
div {
color: red;
}
}
div {
color: blue;
}
As part of looking at Declarative CSS Modules, TAG has suggested that we should investigate
@sheet
as a possible direction. This explainer summarizes and builds on the CSSWG discussion about this idea to consolidate it into a single location.