Skip to content

Commit

Permalink
fix(transformer-directives): extra semicolon (#3658)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Mar 26, 2024
1 parent b9ab39d commit 112f256
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/transformer-directives/src/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ export async function parseApply({ code, uno, offset, applyVariable }: Transform
if (target)
target[2] += item[2]
else
// use spread operator to prevent reassign to uno internal cache
// use spread operator to prevent reassign to uno internal cache
acc.push([...item] as Writeable<StringifiedUtil>)
return acc
}, [] as Writeable<StringifiedUtil>[])

if (!utils.length)
return
const simicolonOffset = code.toString()[childNode.loc!.end.offset] === ';' ? 1 : 0

for (const i of utils) {
const [, _selector, body, parent] = i
Expand Down Expand Up @@ -98,13 +99,13 @@ export async function parseApply({ code, uno, offset, applyVariable }: Transform
else {
// If nested css was scoped, put them last.
if (body.includes('@'))
code.appendRight(code.original.length, body)
code.appendRight(code.original.length + simicolonOffset, body)
else
code.appendRight(calcOffset(childNode!.loc!.end.offset), body)
code.appendRight(calcOffset(childNode!.loc!.end.offset + simicolonOffset), body)
}
}
code.remove(
calcOffset(childNode!.loc!.start.offset),
calcOffset(childNode!.loc!.end.offset),
calcOffset(childNode!.loc!.end.offset + simicolonOffset),
)
}

0 comments on commit 112f256

Please sign in to comment.