-
Notifications
You must be signed in to change notification settings - Fork 116
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
layers support #483
Merged
RyanZim
merged 4 commits into
postcss:master
from
romainmenke:cascade-layers-support--ambitious-squid-0472bea492
Mar 22, 2022
Merged
layers support #483
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict" | ||
|
||
module.exports = function (parentLayer, childLayer) { | ||
if (!parentLayer.length && childLayer.length) return childLayer | ||
if (parentLayer.length && !childLayer.length) return parentLayer | ||
if (!parentLayer.length && !childLayer.length) return [] | ||
|
||
return parentLayer.concat(childLayer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@layer foo { | ||
foo {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@layer layer-alpha, layer-beta.one; | ||
|
||
@import "foo.css" layer; | ||
@import 'bar.css' layer(bar); | ||
@import 'bar.css' layer(bar) level-1 and level-2; | ||
@import url(baz.css) layer; | ||
@import url("foobar.css") layer(foobar); | ||
@import url("foo-layered.css") layer(foo-layered); | ||
|
||
content{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@layer layer-alpha, layer-beta.one; | ||
@layer{ | ||
foo{} | ||
} | ||
@layer bar{ | ||
bar{} | ||
} | ||
@media level-1 and level-2{ | ||
@layer bar{ | ||
bar{} | ||
} | ||
} | ||
@layer{ | ||
baz{} | ||
} | ||
@layer foobar{ | ||
foobar{} | ||
} | ||
@layer foo-layered{ | ||
@layer foo { | ||
foo {} | ||
} | ||
} | ||
content{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict" | ||
// external tooling | ||
const test = require("ava") | ||
|
||
// internal tooling | ||
const checkFixture = require("./helpers/check-fixture") | ||
|
||
test("should resolve layers of import statements", checkFixture, "layer") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not saying this is wrong, but can you show where the spec allows for empty
@layer
before@import
?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.
https://drafts.csswg.org/css-cascade-5/#at-import
https://drafts.csswg.org/css-cascade-5/#layer-block
In more detail : https://drafts.csswg.org/css-cascade-5/#layer-empty
But now that I have some distance since writing this I think that
empty @layer
is not a useful way to describe this to stylesheet authors.I had to look it up, both to check that I didn't make a mistake and what the exact meaning was.
Is there a better, more widely used name for at-rules without a block?
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.
I don't know if there's a good name for it; I think following the spec's wording is a safe bet.
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.
That works for me!
We can also see if this causes confusion to authors and adjust if needed.
It might be a non issue as people learn the feature.
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.
@RyanZim Is this resolved or do you want me to change something?
Not in any rush to have this shipped, but wasn't sure :)
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.
All set, just need to merge and release this when I get a chance.