Skip to content

Commit 60de03c

Browse files
committed
alternative fix
1 parent 7c321a4 commit 60de03c

File tree

1 file changed

+8
-16
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+8
-16
lines changed

packages/svelte/src/internal/client/dom/blocks/each.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ function reconcile(state, array, anchor, flags, get_key) {
503503
current = item.next;
504504
}
505505

506-
let has_offscreen_items = items.size > length;
507-
508506
if (current !== null || seen !== undefined) {
509507
var to_destroy = seen === undefined ? [] : array_from(seen);
510508

@@ -518,8 +516,6 @@ function reconcile(state, array, anchor, flags, get_key) {
518516

519517
var destroy_length = to_destroy.length;
520518

521-
has_offscreen_items = items.size - destroy_length > length;
522-
523519
if (destroy_length > 0) {
524520
var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
525521

@@ -537,18 +533,6 @@ function reconcile(state, array, anchor, flags, get_key) {
537533
}
538534
}
539535

540-
// Append offscreen items at the end
541-
if (has_offscreen_items) {
542-
for (const item of items.values()) {
543-
if (!item.o) {
544-
link(state, prev, item);
545-
prev = item;
546-
}
547-
}
548-
}
549-
550-
state.effect.last = prev && prev.e;
551-
552536
if (is_animated) {
553537
queue_micro_task(() => {
554538
if (to_animate === undefined) return;
@@ -653,6 +637,10 @@ function link(state, prev, next) {
653637
state.first = next;
654638
state.effect.first = next && next.e;
655639
} else {
640+
if (prev.e === state.effect.last && next !== null) {
641+
state.effect.last = next.e;
642+
}
643+
656644
if (prev.e.next) {
657645
prev.e.next.prev = null;
658646
}
@@ -664,6 +652,10 @@ function link(state, prev, next) {
664652
if (next === null) {
665653
state.effect.last = prev && prev.e;
666654
} else {
655+
if (next.e === state.effect.last && prev === null) {
656+
state.effect.last = next.e.prev;
657+
}
658+
667659
if (next.e.prev) {
668660
next.e.prev.next = null;
669661
}

0 commit comments

Comments
 (0)