Skip to content

Commit

Permalink
fix: comma
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 4, 2023
1 parent 3990807 commit 29bc6b1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,13 @@ export function compileScript(
if (node.type === 'VariableDeclaration' && !node.declare) {
const total = node.declarations.length
let left = total
const removed = new Set()

function getLastIndex(i: number) {
while (removed.has(--i)) {}
return i
}

for (let i = 0; i < total; i++) {
const decl = node.declarations[i]
if (decl.init) {
Expand All @@ -1227,14 +1234,15 @@ export function compileScript(
let end = decl.end! + startOffset
if (i === total - 1) {
// last one, locate the end of the prev
start = node.declarations[i - 1].end! + startOffset
start = node.declarations[getLastIndex(i)].end! + startOffset
} else {
// not last one, locate the start of the next
end = node.declarations[i + 1].start! + startOffset
}
s.remove(start, end)
left--
}
removed.add(i)
}
}
}
Expand Down

0 comments on commit 29bc6b1

Please sign in to comment.