Skip to content

Commit a570863

Browse files
committed
fix: comma
1 parent e5d0d8e commit a570863

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
@@ -1205,6 +1205,13 @@ export function compileScript(
12051205
if (node.type === 'VariableDeclaration' && !node.declare) {
12061206
const total = node.declarations.length
12071207
let left = total
1208+
const removed = new Set()
1209+
1210+
function getLastIndex(i: number) {
1211+
while (removed.has(--i)) {}
1212+
return i
1213+
}
1214+
12081215
for (let i = 0; i < total; i++) {
12091216
const decl = node.declarations[i]
12101217
if (decl.init) {
@@ -1221,14 +1228,15 @@ export function compileScript(
12211228
let end = decl.end! + startOffset
12221229
if (i === total - 1) {
12231230
// last one, locate the end of the prev
1224-
start = node.declarations[i - 1].end! + startOffset
1231+
start = node.declarations[getLastIndex(i)].end! + startOffset
12251232
} else {
12261233
// not last one, locate the start of the next
12271234
end = node.declarations[i + 1].start! + startOffset
12281235
}
12291236
s.remove(start, end)
12301237
left--
12311238
}
1239+
removed.add(i)
12321240
}
12331241
}
12341242
}

0 commit comments

Comments
 (0)