MCPcopy
hub / github.com/sveltejs/svelte / destroy_effects

Function destroy_effects

packages/svelte/src/internal/client/dom/blocks/each.js:135–162  ·  view source on GitHub ↗

* @param {EachState} state * @param {Effect[]} to_destroy * @param {boolean} remove_dom

(state, to_destroy, remove_dom = true)

Source from the content-addressed store, hash-verified

133 * @param {boolean} remove_dom
134 */
135function destroy_effects(state, to_destroy, remove_dom = true) {
136 /** @type {Set<Effect> | undefined} */
137 var preserved_effects;
138
139 // The loop-in-a-loop isn't ideal, but we should only hit this in relatively rare cases
140 if (state.pending.size > 0) {
141 preserved_effects = new Set();
142
143 for (const keys of state.pending.values()) {
144 for (const key of keys) {
145 preserved_effects.add(/** @type {EachItem} */ (state.items.get(key)).e);
146 }
147 }
148 }
149
150 for (var i = 0; i < to_destroy.length; i++) {
151 var e = to_destroy[i];
152
153 if (preserved_effects?.has(e)) {
154 e.f |= EFFECT_OFFSCREEN;
155
156 const fragment = document.createDocumentFragment();
157 move_effect(e, fragment);
158 } else {
159 destroy_effect(to_destroy[i], remove_dom);
160 }
161 }
162}
163
164/** @type {TemplateNode} */
165var offscreen_anchor;

Callers 2

pause_effectsFunction · 0.85
reconcileFunction · 0.85

Calls 6

move_effectFunction · 0.90
destroy_effectFunction · 0.90
valuesMethod · 0.45
addMethod · 0.45
getMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected