-
Notifications
You must be signed in to change notification settings - Fork 661
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
[css-cascade-5] Proposal to disallow interleaving of @layer and @import rules #6522
Comments
I don't think this would cause any functional problems - authors can still order layers as they want, and then add imported styles to those layers. But it does make the syntax for that a bit less flexible. |
Yeah, no functionality is lost here, just a bit of flexibility. But I'd be okay with the restriction; it's probably better practice to put your |
Agenda+ to get a resolution |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> Topic: disallow interweaving of @import and @layer<TabAtkins> github: https://github.com//issues/6522 <TabAtkins> miriam: xiaochang is working on a cascade layers impl, and was concerned about allowing `@layers ...;`rules allowed anywhere in the doc, including between @imports <TabAtkins> miriam: He's suggesting instead we just allow them before or after all the imports, but not between <TabAtkins> miriam: I think that's fine; there's no functionality loss, just a little bit of flexibility. I'm fine with this. <fantasai> wfm <chrishtr> +1 <TabAtkins> Rossen_: Seeing support, any other opinions? Objections? <emilio> q+ <chris> ping <Rossen_> ack emilio <TabAtkins> emilio: I'd argue we shoudl only allow after <TabAtkins> emilio: The less syntax we have to mess with preload scanners the better <TabAtkins> miriam: That actually does reduce functionality, we need to be able to order layers before we import them <TabAtkins> emilio: That means the scanners need to deal with this <TabAtkins> emilio: Do we also allow the block syntax? <TabAtkins> fantasai: No, we disallow that intentionally <TabAtkins> emilio: Okay, as long as there's no arbitrary blocks before the imports it's okay <Rossen_> q? <TabAtkins> RESOLVED: @layer statements must occur before or after all @imports, not interleaved |
@mirisuzanne Your edits also disallow interleaving among |
@fantasai That was a request from @xiaochengh, as I understand it had to do with the same parsing/performance concerns mentioned above. Maybe he can speak to it more here. |
Yes, I requested that the rules should follow the exact ordering I initially proposed. The reason is that there's no loss of functionality, and the implementation in Chromium gets much simpler. |
I see that the spec got adjusted in ed81c17 for this, but I'm a bit confused by the use of the word "They" in the note.
That "They", does it mean:
A few thoughts that go with all these options:
I think option 2 is meant, but I'm not really sure reading all comments and logs here, as it's not explicitly mentioned 🤔 |
@bramus option 1 is the intended behavior, though it's only intended to mean that any |
Thanks for the clarifications on that, @mirisuzanne. Think I get it now: /* EXAMPLE 31 */
@layer default;
@import url(theme.css) layer(theme);
@layer components; /* 👈 This @layer statement here will make all subsequent @import rules be ignored. In this example however there are none */
@layer default {
audio[controls] {
display: block;
}
} I see that in d9fdc1e you changed the text to “A ''@layer'' rule that comes after …”. More precise would be “A ''@layer'' statement at-rule that comes after …”? Winging back to “the @layer block at-rule” described just above it. There it reads in a note:
Is that 1 @import rule in between two @layers block at-rules? If so, I somewhat read between the lines that best practice that's being hinted at is to:
Would that be something to recommend people to do? (Apologies if I'm asking too many stupid questions regarding this. Trying to understand things correctly here. Perhaps some code-examples of what is meant by all those limitations could help? In css-nesting-1 for example I see a lot of these “wrong examples“ with an explanation of what exactly is wrong added to them.) |
@bramus Yes, your summary of best practice is correct. Though another common practice is to avoid using Only the empty layer-ordering statements are allowed before |
Thanks again for the extra input there. Current spec text indeed is correct; wanted to verify if I laid the pieces together correctly :) |
Disabled, and of course doing nothing for now still, but this is another piece that is useful to get reviewed separately. Don't allow layers to be interleaved with @import / @namespace rules as per w3c/csswg-drafts#6522. Differential Revision: https://phabricator.services.mozilla.com/D124229
Disabled, and of course doing nothing for now still, but this is another piece that is useful to get reviewed separately. Don't allow layers to be interleaved with @import / @namespace rules as per w3c/csswg-drafts#6522. Differential Revision: https://phabricator.services.mozilla.com/D124229
Disabled, and of course doing nothing for now still, but this is another piece that is useful to get reviewed separately. Don't allow layers to be interleaved with @import / @namespace rules as per w3c/csswg-drafts#6522. Differential Revision: https://phabricator.services.mozilla.com/D124229
Regarding empty @layer statements, the current spec says:
And also:
This allows interleaving @layer and @import rules. I'm proposing to disallow it because:
The exact proposal is that rules in a style sheet must follow this ordering:
The text was updated successfully, but these errors were encountered: