Skip to content

Commit 0a8a4a0

Browse files
committed
postcss-extract : fix
1 parent 8f82385 commit 0a8a4a0

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

plugins/postcss-extract/.tape.mjs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,34 @@ postcssTape(plugin)({
77
message: "Can extract custom props from root",
88
options: {
99
queries: {
10-
'custom-props-in-root': 'rule[selector*=":ROOT" i] decl[variable]'
10+
'custom-props-in-root': 'rule[selector*=":ROOT" i] decl[variable]',
11+
'not-variable': 'decl:not([variable])'
1112
},
1213
results: function(results) {
1314
assert.deepStrictEqual(
14-
results,
15-
{
16-
'custom-props-in-root': [
17-
{ type: 'decl', prop: '--foo', value: '1', variable: true },
18-
{
19-
type: 'decl',
20-
prop: '--bar',
21-
value: 'calc(1px * 100)',
22-
variable: true
23-
},
24-
{ type: 'decl', prop: '--baz', value: '"a value"', variable: true }
25-
]
26-
}
15+
results['custom-props-in-root'],
16+
[
17+
{ type: 'decl', prop: '--foo', value: '1', variable: true },
18+
{
19+
type: 'decl',
20+
prop: '--bar',
21+
value: 'calc(1px * 100)',
22+
variable: true
23+
},
24+
{ type: 'decl', prop: '--baz', value: '"a value"', variable: true }
25+
]
26+
)
27+
28+
assert.deepStrictEqual(
29+
results['not-variable'],
30+
[
31+
{
32+
type: 'decl',
33+
prop: 'not-a-variable',
34+
value: '1',
35+
variable: false
36+
}
37+
]
2738
)
2839
}
2940
}

plugins/postcss-extract/src/select-nodes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function buildQuery(selector: selectorParser.Selector) {
100100
break;
101101
default:
102102
currentCondition = {
103+
next: currentCondition,
103104
run: (): NodeList => {
104105
return [];
105106
},
@@ -120,6 +121,7 @@ function buildQuery(selector: selectorParser.Selector) {
120121
switch (selectorPart.value) {
121122
case ':not': {
122123
currentCondition = {
124+
next: currentCondition,
123125
run: (list: NodeList): NodeList => {
124126
const notQueries = selectorPart.nodes.map((notSelectorPart) => {
125127
return buildQuery(notSelectorPart);
@@ -138,6 +140,7 @@ function buildQuery(selector: selectorParser.Selector) {
138140
}
139141
default:
140142
currentCondition = {
143+
next: currentCondition,
141144
run: (): NodeList => {
142145
return [];
143146
},
@@ -186,6 +189,7 @@ function buildQuery(selector: selectorParser.Selector) {
186189
}
187190
default:
188191
currentCondition = {
192+
next: currentCondition,
189193
run: (): NodeList => {
190194
return [];
191195
},

0 commit comments

Comments
 (0)