Skip to content

Commit 75cbc4e

Browse files
committed
incorrectly expand nesting rules #38
1 parent ce31beb commit 75cbc4e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/lib/ast/expand.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,25 @@ function expandRule(node: AstRule): Array<AstRule | AstAtRule> {
8282
if (!rule.sel.includes('&')) {
8383

8484
const selRule: string[][] = splitRule(rule.sel);
85-
selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
8685

87-
rule.sel = selRule.reduce((acc: string[], curr: string[]) => {
86+
if (selRule.length > 1) {
8887

89-
acc.push(curr.join(''));
88+
const r: string = ':is(' + selRule.map(a => a.join('')).join(',') + ')';
89+
90+
rule.sel = splitRule(ast.sel).reduce((a, b) => a.concat([b.join('') + r]), <string[]>[]).join(',');
91+
}
92+
93+
else {
94+
95+
selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
96+
rule.sel = selRule.reduce((acc: string[], curr: string[]) => {
97+
98+
acc.push(curr.join(''));
99+
100+
return acc;
101+
}, <string[]>[]).join(',');
102+
}
90103

91-
return acc;
92-
}, <string[]>[]).join(',');
93104
} else {
94105

95106
rule.sel = replaceCompound(rule.sel, ast.sel);

0 commit comments

Comments
 (0)