Skip to content

Commit dcb85a1

Browse files
committed
chore: tweak each block runtime logic
1 parent 3c87a69 commit dcb85a1

File tree

1 file changed

+19
-17
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+19
-17
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,31 +394,33 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
394394

395395
const to_destroy = Array.from(seen);
396396

397-
while (current) {
397+
while (current !== null) {
398398
to_destroy.push(current);
399399
current = current.next;
400400
}
401401

402-
var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
402+
if (to_destroy.length > 0) {
403+
var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
403404

404-
if (is_animated) {
405-
for (i = 0; i < to_destroy.length; i += 1) {
406-
to_destroy[i].a?.measure();
407-
}
405+
if (is_animated) {
406+
for (i = 0; i < to_destroy.length; i += 1) {
407+
to_destroy[i].a?.measure();
408+
}
408409

409-
for (i = 0; i < to_destroy.length; i += 1) {
410-
to_destroy[i].a?.fix();
410+
for (i = 0; i < to_destroy.length; i += 1) {
411+
to_destroy[i].a?.fix();
412+
}
411413
}
412-
}
413414

414-
pause_effects(to_destroy, controlled_anchor, () => {
415-
for (var i = 0; i < to_destroy.length; i += 1) {
416-
var item = to_destroy[i];
417-
items.delete(item.k);
418-
item.o.remove();
419-
link(item.prev, item.next);
420-
}
421-
});
415+
pause_effects(to_destroy, controlled_anchor, () => {
416+
for (var i = 0; i < to_destroy.length; i += 1) {
417+
var item = to_destroy[i];
418+
items.delete(item.k);
419+
item.o.remove();
420+
link(item.prev, item.next);
421+
}
422+
});
423+
}
422424

423425
if (is_animated) {
424426
effect(() => {

0 commit comments

Comments
 (0)