Skip to content

Commit 31e5edc

Browse files
committed
fix: deep group-modifier loop stuck issue
1 parent 955b0cd commit 31e5edc

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/twcss-to-sass.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ function groupUtilityToSass(
271271
} else if (node.children.length) {
272272
groupUtilityToSass(node.children, ++deepth, true)
273273
}
274+
} else {
275+
groupUtilityToSass(node.children, ++deepth, true)
274276
}
275277
}
276278
})
@@ -309,14 +311,6 @@ function groupUtilityToSass(
309311
})
310312

311313
groupSass += `}\n\n`
312-
313-
// const classList = _utilityList
314-
// .map((x: IGroupModifierPair) => x.utility)
315-
// .join(' ')
316-
317-
// groupSass += `&:${modifier} {\n`
318-
// groupSass += `\t@apply ${classList};\n`
319-
// groupSass += `}\n`
320314
})
321315
}
322316

@@ -353,9 +347,6 @@ function getSassTree(nodeTree: IHtmlNode[], deepth = 0) {
353347
? `@apply ${node.filterAttributes.class};`
354348
: ''
355349

356-
// remove group class
357-
tailwindClassList = tailwindClassList.replace(/(group)(?!-)/gm, ' ')
358-
359350
treeString += tailwindClassList
360351
}
361352

@@ -383,12 +374,15 @@ function getSassTree(nodeTree: IHtmlNode[], deepth = 0) {
383374

384375
let groupUtilityTree = ''
385376

386-
if (node.filterAttributes?.class?.match(/(group)(?!-)/gm)) {
377+
if (node.filterAttributes?.class?.match(/ (group)(?!-)/gm)) {
387378
groupUtilityTree = groupUtilityToSass(node.children, deepth)
388379

389380
if (groupUtilityTree !== '') {
390381
treeString += groupUtilityTree
391382

383+
// clear parent group class name
384+
treeString = treeString.replace(/(group)(?!-)/gm, ' ')
385+
392386
// clear group modifier classes from @apply
393387
subTreeString = subTreeString.replace(
394388
/ group-([a-z0-9]+):([a-z0-9-:\/]+)/gm,

0 commit comments

Comments
 (0)