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