Skip to content

Commit 0fdd50d

Browse files
committed
docs
1 parent aa64002 commit 0fdd50d

File tree

1 file changed

+9
-0
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+9
-0
lines changed

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ export function destroy_effect(effect) {
259259
}
260260

261261
/**
262+
* When a block effect is removed, we don't immediately destroy it or yank it
263+
* out of the DOM, because it might have transitions. Instead, we 'pause' it.
264+
* It stays around (in memory, and in the DOM) until outro transitions have
265+
* completed, and if the state change is reversed then we _resume_ it.
266+
* A paused effect does not update, and the DOM subtree becomes inert.
262267
* @param {import('#client').Effect} effect
263268
* @param {() => void} callback
264269
*/
@@ -313,6 +318,8 @@ function pause_children(effect, transitions, local) {
313318
}
314319

315320
/**
321+
* The opposite of `pause_effect`. We call this if (for example)
322+
* `x` becomes falsy then truthy: `{#if x}...{/if}`
316323
* @param {import('#client').Effect} effect
317324
*/
318325
export function resume_effect(effect) {
@@ -327,6 +334,8 @@ function resume_children(effect, local) {
327334
if ((effect.f & INERT) === 0) return;
328335
effect.f ^= INERT;
329336

337+
// If a dependency of this effect changed while it was paused,
338+
// apply the change now
330339
if (check_dirtiness(effect)) {
331340
execute_effect(effect);
332341
}

0 commit comments

Comments
 (0)