Skip to content

Commit 47a3b2c

Browse files
committed
Process only direct child of root
`supports` can have a `media`. We should not break this nested structure, so keep nested `media` as it is. This fixes hail2u#50.
1 parent 7b11b59 commit 47a3b2c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ module.exports = postcss.plugin(pkg.name, (opts) => {
160160
}
161161

162162
css.walkAtRules("media", (atRule) => {
163+
if (atRule.parent.type !== "root") {
164+
return;
165+
}
166+
163167
const queryList = atRule.params;
164168
const past = queries[queryList];
165169

test/expected/issue50.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.foo {
2+
z-index: 1;
3+
}
4+
5+
@supports (display: auto) {
6+
.foo {
7+
z-index: 2;
8+
}
9+
10+
@media (min-width: 1024px) {
11+
.foo {
12+
z-index: 3;
13+
}
14+
}
15+
}
16+
17+
@media (min-width: 1024px) {
18+
.foo {
19+
z-index: 4;
20+
}
21+
}

test/fixtures/issue50.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.foo {
2+
z-index: 1;
3+
}
4+
5+
@media (min-width: 1024px) {
6+
.foo {
7+
z-index: 4;
8+
}
9+
}
10+
11+
@supports (display: auto) {
12+
.foo {
13+
z-index: 2;
14+
}
15+
16+
@media (min-width: 1024px) {
17+
.foo {
18+
z-index: 3;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)