-
Notifications
You must be signed in to change notification settings - Fork 8
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
Problem with Nested media queries #38
Comments
I can confirm this is an issue. Here is the code example where the sorting logic fails: @custom-media --breakpoint-sm (min-width: 600px);
@custom-media --hover-check (hover: hover);
.link {
color: blue;
@media (--hover-check) {
&:hover {
color: red;
}
}
@media (--breakpoint-sm) {
color: green;
@media (--hover-check) {
&:hover {
color: pink;
}
}
}
} Which results to: .link {
color: blue;
}
@media (min-width: 600px){
.link {
color: green
}
@media (hover: hover) {
.link:hover {
color: pink;
}
}
}
@media (hover: hover){
.link:hover {
color: red;
}
.link:hover {
color: pink;
}
} Instead of: .link {
color: blue;
}
@media (hover: hover) {
.link:hover {
color: red;
}
}
@media (min-width: 600px) {
.link {
color: green
}
@media (hover: hover) {
.link:hover {
color: pink;
}
}
} |
@iamskok need your configuration because i have different result for your example without sorting
Result without sorting.link {
color: blue;
}
@media (hover: hover) {
.link:hover {
color: red;
}
}
@media (min-width: 600px) {
.link {
color: green;
}
}
@media (min-width: 600px) and (hover: hover) {
.link:hover {
color: pink;
}
} |
Hi @yunusga, I also have a repro of this issue: https://codesandbox.io/s/postcss-forked-vw07gs?file=/src/index.js:102-192. Input:
Output:
Expected output (same as input):
|
Hi @jimmy-guo, thanks, yes, that's right, I am aware of this problem, I will add an update soon. I didn't do this functionality because Firefox still doesn't support it https://caniuse.com/css-nesting |
Linked issue OlehDutchenko/sort-css-media-queries#24 |
@iamskok, @jimmy-guo, @pavel-klimov I added quick fix for problem with ejected nested media queries postcss-sort-media-queries/blob/v5.2.0/README.md#only-top-level |
Hi!
It think that I found problem in this plugin. CSS allows nesting at-rules. The plugin ignores this.
Problem
Minimum code example:
Result:
But the code shouldn't have changed.
It's my case and I solved it with option in postcss-preset-env
My solution won't help with other at-rules. For example:
My environment:
The text was updated successfully, but these errors were encountered: