Skip to content

Commit

Permalink
incorrectly expand nesting rules #38
Browse files Browse the repository at this point in the history
  • Loading branch information
tbela99 committed Jun 23, 2024
1 parent ce31beb commit 75cbc4e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/lib/ast/expand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,25 @@ function expandRule(node: AstRule): Array<AstRule | AstAtRule> {
if (!rule.sel.includes('&')) {

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

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

acc.push(curr.join(''));
const r: string = ':is(' + selRule.map(a => a.join('')).join(',') + ')';

rule.sel = splitRule(ast.sel).reduce((a, b) => a.concat([b.join('') + r]), <string[]>[]).join(',');
}

else {

selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
rule.sel = selRule.reduce((acc: string[], curr: string[]) => {

acc.push(curr.join(''));

return acc;
}, <string[]>[]).join(',');
}

return acc;
}, <string[]>[]).join(',');
} else {

rule.sel = replaceCompound(rule.sel, ast.sel);
Expand Down

0 comments on commit 75cbc4e

Please sign in to comment.