Skip to content

Commit c3007b1

Browse files
committed
refactor: remove unnecessary depth number
1 parent e9f5c8b commit c3007b1

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/twcss-to-sass.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,12 @@ let groupModifierList: IGroupModifierPair[] = []
234234
* Convert group-* modifiers to sub-selectors
235235
*
236236
* @param nodeTree IHtmlNode[]
237-
* @param deepth number
238237
* @param isChildNodes boolean
239238
*
240239
* @returns string
241240
*/
242241
function groupUtilityToSass(
243242
nodeTree: IHtmlNode[],
244-
deepth: number,
245243
isChildNodes = false
246244
): string {
247245
if (!isChildNodes) {
@@ -264,7 +262,7 @@ function groupUtilityToSass(
264262
const groupModifierPair = <IGroupModifierPair>{
265263
modifier: matches?.[1],
266264
utility: matches?.[2],
267-
className: getClassName(node, deepth),
265+
className: getClassName(node, node.order),
268266
}
269267

270268
groupModifierList.push(groupModifierPair)
@@ -273,10 +271,10 @@ function groupUtilityToSass(
273271
if (node.filterAttributes.class.match(/(group)(?!-)/gm)) {
274272
return groupSass
275273
} else if (node.children.length) {
276-
groupUtilityToSass(node.children, ++deepth, true)
274+
groupUtilityToSass(node.children, true)
277275
}
278276
} else {
279-
groupUtilityToSass(node.children, ++deepth, true)
277+
groupUtilityToSass(node.children, true)
280278
}
281279
}
282280
})
@@ -377,7 +375,7 @@ function getSassTree(nodeTree: IHtmlNode[]) {
377375

378376
// convert group utilities
379377
if (node.filterAttributes?.class?.match(/ (group)(?!-)/gm)) {
380-
groupUtilityTree = groupUtilityToSass(node.children, node.order)
378+
groupUtilityTree = groupUtilityToSass(node.children)
381379

382380
if (groupUtilityTree !== '') {
383381
treeString += groupUtilityTree

test/twcss-to-sass.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ test('convert to sass with group-modifier', () => {
113113
/* #region Group modifier: hover */
114114
115115
&:hover {
116-
.class-div-1 {
116+
.class-div-2 {
117117
@apply opacity-100 bg-gradient-to-t;
118118
}
119119
}

0 commit comments

Comments
 (0)