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 @@ -1211,6 +1211,13 @@ export function compileScript(
1211
1211
if ( node . type === 'VariableDeclaration' && ! node . declare ) {
1212
1212
const total = node . declarations . length
1213
1213
let left = total
1214
+ const removed = new Set ( )
1215
+
1216
+ function getLastIndex ( i : number ) {
1217
+ while ( removed . has ( -- i ) ) { }
1218
+ return i
1219
+ }
1220
+
1214
1221
for ( let i = 0 ; i < total ; i ++ ) {
1215
1222
const decl = node . declarations [ i ]
1216
1223
if ( decl . init ) {
@@ -1227,14 +1234,15 @@ export function compileScript(
1227
1234
let end = decl . end ! + startOffset
1228
1235
if ( i === total - 1 ) {
1229
1236
// last one, locate the end of the prev
1230
- start = node . declarations [ i - 1 ] . end ! + startOffset
1237
+ start = node . declarations [ getLastIndex ( i ) ] . end ! + startOffset
1231
1238
} else {
1232
1239
// not last one, locate the start of the next
1233
1240
end = node . declarations [ i + 1 ] . start ! + startOffset
1234
1241
}
1235
1242
s . remove ( start , end )
1236
1243
left --
1237
1244
}
1245
+ removed . add ( i )
1238
1246
}
1239
1247
}
1240
1248
}
You can’t perform that action at this time.
0 commit comments