Skip to content

Commit 7429e54

Browse files
authored
chore: more tweaks to each block performance (#11863)
* chore: more tweaks to each block performance * chore: more tweaks to each block performance
1 parent ef2d378 commit 7429e54

File tree

1 file changed

+7
-13
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+7
-13
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export function index(_, i) {
5757
* subsequent destruction. Used in each blocks
5858
* @param {import('#client').EachItem[]} items
5959
* @param {null | Node} controlled_anchor
60-
* @param {() => void} [callback]
60+
* @param {Map<any, import("#client").EachItem>} items_map
6161
*/
62-
function pause_effects(items, controlled_anchor, callback) {
62+
function pause_effects(items, controlled_anchor, items_map) {
6363
/** @type {import('#client').TransitionManager[]} */
6464
var transitions = [];
6565
var length = items.length;
@@ -81,10 +81,11 @@ function pause_effects(items, controlled_anchor, callback) {
8181

8282
run_out_transitions(transitions, () => {
8383
for (var i = 0; i < length; i++) {
84-
destroy_effect(items[i].e, !is_controlled);
84+
var item = items[i];
85+
items_map.delete(item.k);
86+
link(item.prev, item.next);
87+
destroy_effect(item.e, !is_controlled);
8588
}
86-
87-
if (callback !== undefined) callback();
8889
});
8990
}
9091

@@ -413,14 +414,7 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
413414
}
414415
}
415416

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

426420
if (is_animated) {

0 commit comments

Comments
 (0)