@@ -314,25 +314,35 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
314
314
315
315
prev = start . prev ;
316
316
317
+ var a = matched [ 0 ] ;
318
+ var b = matched [ matched . length - 1 ] ;
319
+
320
+ link ( a . prev , b . next ) ;
321
+ link ( prev , a ) ;
322
+ link ( b , start ) ;
323
+
317
324
for ( j = 0 ; j < matched . length ; j += 1 ) {
318
- item = matched [ j ] ;
319
- move ( item , prev , local_anchor ) ;
320
- prev = item ;
325
+ move ( matched [ j ] , local_anchor ) ;
321
326
}
322
327
323
328
for ( j = 0 ; j < stashed . length ; j += 1 ) {
324
329
seen . delete ( stashed [ j ] ) ;
325
330
}
326
331
327
332
current = start ;
333
+ prev = b ;
328
334
i -= 1 ;
329
335
330
336
matched = [ ] ;
331
337
stashed = [ ] ;
332
338
} else {
333
339
// more efficient to move earlier items to the back
334
340
seen . delete ( item ) ;
335
- move ( item , prev , current ? get_first_child ( current ) : anchor ) ;
341
+ move ( item , current ? get_first_child ( current ) : anchor ) ;
342
+
343
+ link ( item . prev , item . next ) ;
344
+ link ( item , prev . next ) ;
345
+ link ( prev , item ) ;
336
346
337
347
prev = item ;
338
348
}
@@ -470,10 +480,9 @@ function create_item(anchor, prev, next, value, key, index, render_fn, flags) {
470
480
471
481
/**
472
482
* @param {import('#client').EachItem } item
473
- * @param {import('#client').EachItem | import('#client').EachState } prev
474
483
* @param {Text | Element | Comment } anchor
475
484
*/
476
- function move ( item , prev , anchor ) {
485
+ function move ( item , anchor ) {
477
486
var dom = item . e . dom ;
478
487
479
488
if ( dom !== null ) {
@@ -485,10 +494,6 @@ function move(item, prev, anchor) {
485
494
anchor . before ( dom ) ;
486
495
}
487
496
}
488
-
489
- link ( item . prev , item . next ) ;
490
- link ( item , prev . next ) ;
491
- link ( prev , item ) ;
492
497
}
493
498
494
499
/**
0 commit comments