Skip to content

Commit 29bc6b1

Browse files
committed
fix: comma
1 parent 3990807 commit 29bc6b1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/compiler-sfc/src/compileScript.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,13 @@ export function compileScript(
12111211
if (node.type === 'VariableDeclaration' && !node.declare) {
12121212
const total = node.declarations.length
12131213
let left = total
1214+
const removed = new Set()
1215+
1216+
function getLastIndex(i: number) {
1217+
while (removed.has(--i)) {}
1218+
return i
1219+
}
1220+
12141221
for (let i = 0; i < total; i++) {
12151222
const decl = node.declarations[i]
12161223
if (decl.init) {
@@ -1227,14 +1234,15 @@ export function compileScript(
12271234
let end = decl.end! + startOffset
12281235
if (i === total - 1) {
12291236
// last one, locate the end of the prev
1230-
start = node.declarations[i - 1].end! + startOffset
1237+
start = node.declarations[getLastIndex(i)].end! + startOffset
12311238
} else {
12321239
// not last one, locate the start of the next
12331240
end = node.declarations[i + 1].start! + startOffset
12341241
}
12351242
s.remove(start, end)
12361243
left--
12371244
}
1245+
removed.add(i)
12381246
}
12391247
}
12401248
}

0 commit comments

Comments
 (0)