Skip to content

Commit 86c119b

Browse files
committed
fix: comma
1 parent b9721f8 commit 86c119b

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
@@ -1251,6 +1251,13 @@ export function compileScript(
12511251
if (node.type === 'VariableDeclaration' && !node.declare) {
12521252
const total = node.declarations.length
12531253
let left = total
1254+
const removed = new Set()
1255+
1256+
function getLastIndex(i: number) {
1257+
while (removed.has(--i)) {}
1258+
return i
1259+
}
1260+
12541261
for (let i = 0; i < total; i++) {
12551262
const decl = node.declarations[i]
12561263
if (decl.init) {
@@ -1274,14 +1281,15 @@ export function compileScript(
12741281
let end = decl.end! + startOffset
12751282
if (i === total - 1) {
12761283
// last one, locate the end of the prev
1277-
start = node.declarations[i - 1].end! + startOffset
1284+
start = node.declarations[getLastIndex(i)].end! + startOffset
12781285
} else {
12791286
// not last one, locate the start of the next
12801287
end = node.declarations[i + 1].start! + startOffset
12811288
}
12821289
s.remove(start, end)
12831290
left--
12841291
}
1292+
removed.add(i)
12851293
}
12861294
}
12871295
}

0 commit comments

Comments
 (0)