Skip to content

Commit 7b9a015

Browse files
committed
Add root specifiers test
1 parent 5695b77 commit 7b9a015

7 files changed

+115
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
:root {
2+
--size: 32px;
3+
}
4+
5+
:root.dark {
6+
--size: 64px;
7+
}
8+
9+
10+
@media (test) {
11+
:root {
12+
--size: 96px;
13+
}
14+
15+
:root.dark {
16+
--size: 128px;
17+
}
18+
}
19+
20+
:root {
21+
--test-size: var(--size);
22+
}
23+
24+
.hello.world {
25+
background: red;
26+
width: var(--test-size);
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.hello.world {
2+
background: red;
3+
width: 32px;
4+
}
5+
6+
@media (test) {
7+
.hello.world {
8+
width: 96px;
9+
}
10+
}
11+
12+
@media (test) {
13+
:root.dark .hello.world {
14+
width: 128px;
15+
}
16+
}
17+
18+
19+
:root.dark .hello.world {
20+
width: 64px;
21+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:root {
2+
--size: 32px;
3+
}
4+
5+
:root.dark {
6+
--size: 64px;
7+
}
8+
9+
10+
@media (test) {
11+
:root.dark {
12+
--size: 128px;
13+
}
14+
}
15+
16+
:root {
17+
--test-size: var(--size);
18+
}
19+
20+
.hello.world {
21+
background: red;
22+
width: var(--test-size);
23+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.hello.world {
2+
background: red;
3+
width: 32px;
4+
}
5+
6+
@media (test) {
7+
:root.dark .hello.world {
8+
width: 128px;
9+
}
10+
}
11+
12+
:root.dark .hello.world {
13+
width: 64px;
14+
}

test/fixtures/root-specifity.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
:root {
2+
--size: 32px;
3+
}
4+
5+
:root.dark {
6+
--size: 64px;
7+
}
8+
9+
:root {
10+
--test-size: var(--size);
11+
}
12+
13+
.hello.world {
14+
background: red;
15+
width: var(--test-size);
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.hello.world {
2+
background: red;
3+
width: 32px;
4+
}
5+
6+
:root.dark .hello.world {
7+
width: 64px;
8+
}

test/test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ describe('postcss-css-variables', function() {
129129

130130
test('should work with `!important` variable declarations', 'important-variable-declaration');
131131

132-
132+
133+
describe(':root specifiers', () => {
134+
test('specific :root classifiers', 'root-specifity');
135+
test('specific :root classifiers in media queries', 'root-media-specifity');
136+
test('specific :root classifiers in media queries + pure', 'root-media-specifity-combined', { preserveAtRulesOrder: true });
137+
})
133138

134139
describe('with at-rules', function() {
135140
test('should add rule declaration of property in @media', 'media-query');

0 commit comments

Comments
 (0)