Skip to content

Commit 756c350

Browse files
committed
fix
1 parent 79cd5c4 commit 756c350

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ function pause_effects(state, to_destroy, controlled_anchor) {
6969
var remaining = to_destroy.length;
7070

7171
for (var i = 0; i < length; i++) {
72+
let effect = to_destroy[i];
73+
7274
pause_effect(
73-
to_destroy[i],
75+
effect,
7476
() => {
7577
if (group) {
76-
group.remaining -= 1;
78+
group.pending.delete(effect);
79+
group.done.add(effect);
7780

78-
if (group.remaining === 0) {
81+
if (group.pending.size === 0) {
7982
var groups = /** @type {Set<EachOutroGroup>} */ (state.outrogroups);
8083

81-
destroy_effects(Array.from(group.effects));
84+
destroy_effects(array_from(group.done));
8285
groups.delete(group);
8386

8487
if (groups.size === 0) {
@@ -112,8 +115,8 @@ function pause_effects(state, to_destroy, controlled_anchor) {
112115
destroy_effects(to_destroy, !fast_path);
113116
} else {
114117
group = {
115-
remaining,
116-
effects: new Set(to_destroy)
118+
pending: new Set(to_destroy),
119+
done: new Set()
117120
};
118121

119122
(state.outrogroups ??= new Set()).add(group);
@@ -399,10 +402,8 @@ function reconcile(state, array, anchor, flags, get_key) {
399402

400403
if (state.outrogroups !== null) {
401404
for (const group of state.outrogroups) {
402-
if (group.effects.has(effect)) {
403-
group.remaining -= 1;
404-
group.effects.delete(effect);
405-
}
405+
group.pending.delete(effect);
406+
group.done.delete(effect);
406407
}
407408
}
408409

@@ -511,8 +512,8 @@ function reconcile(state, array, anchor, flags, get_key) {
511512

512513
if (state.outrogroups !== null) {
513514
for (const group of state.outrogroups) {
514-
if (group.remaining === 0) {
515-
destroy_effects(Array.from(group.effects));
515+
if (group.pending.size === 0) {
516+
destroy_effects(array_from(group.done));
516517
state.outrogroups?.delete(group);
517518
}
518519
}

packages/svelte/src/internal/client/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export type TemplateNode = Text | Element | Comment;
7373
export type Dom = TemplateNode | TemplateNode[];
7474

7575
export type EachOutroGroup = {
76-
remaining: number;
77-
effects: Set<Effect>;
76+
pending: Set<Effect>;
77+
done: Set<Effect>;
7878
};
7979

8080
export type EachState = {

0 commit comments

Comments
 (0)