File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/compiler-sfc/src Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1251,6 +1251,13 @@ export function compileScript(
1251
1251
if ( node . type === 'VariableDeclaration' && ! node . declare ) {
1252
1252
const total = node . declarations . length
1253
1253
let left = total
1254
+ const removed = new Set ( )
1255
+
1256
+ function getLastIndex ( i : number ) {
1257
+ while ( removed . has ( -- i ) ) { }
1258
+ return i
1259
+ }
1260
+
1254
1261
for ( let i = 0 ; i < total ; i ++ ) {
1255
1262
const decl = node . declarations [ i ]
1256
1263
if ( decl . init ) {
@@ -1274,14 +1281,15 @@ export function compileScript(
1274
1281
let end = decl . end ! + startOffset
1275
1282
if ( i === total - 1 ) {
1276
1283
// last one, locate the end of the prev
1277
- start = node . declarations [ i - 1 ] . end ! + startOffset
1284
+ start = node . declarations [ getLastIndex ( i ) ] . end ! + startOffset
1278
1285
} else {
1279
1286
// not last one, locate the start of the next
1280
1287
end = node . declarations [ i + 1 ] . start ! + startOffset
1281
1288
}
1282
1289
s . remove ( start , end )
1283
1290
left --
1284
1291
}
1292
+ removed . add ( i )
1285
1293
}
1286
1294
}
1287
1295
}
You can’t perform that action at this time.
0 commit comments