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

Function destroy_effect

packages/svelte/src/internal/client/reactivity/effects.js:511–563  ·  view source on GitHub ↗
(effect, remove_dom = true)

Source from the content-addressed store, hash-verified

509 * @returns {void}
510 */
511export function destroy_effect(effect, remove_dom = true) {
512 var removed = false;
513
514 if (
515 (remove_dom || (effect.f & HEAD_EFFECT) !== 0) &&
516 effect.nodes !== null &&
517 effect.nodes.end !== null
518 ) {
519 remove_effect_dom(effect.nodes.start, /** @type {TemplateNode} */ (effect.nodes.end));
520 removed = true;
521 }
522
523 effect.f |= DESTROYING;
524 destroy_effect_children(effect, remove_dom && !removed);
525 remove_reactions(effect, 0);
526
527 var transitions = effect.nodes && effect.nodes.t;
528
529 if (transitions !== null) {
530 for (const transition of transitions) {
531 transition.stop();
532 }
533 }
534
535 execute_effect_teardown(effect);
536
537 effect.f ^= DESTROYING;
538 effect.f |= DESTROYED;
539
540 var parent = effect.parent;
541
542 // If the parent doesn't have any children, then skip this work altogether
543 if (parent !== null && parent.first !== null) {
544 unlink_effect(effect);
545 }
546
547 if (DEV) {
548 effect.component_function = null;
549 }
550
551 // `first` and `child` are nulled out in destroy_effect_children
552 // we don't null out `parent` so that error propagation can work correctly
553 effect.next =
554 effect.prev =
555 effect.teardown =
556 effect.ctx =
557 effect.deps =
558 effect.fn =
559 effect.nodes =
560 effect.ac =
561 effect.b =
562 null;
563}
564
565/**
566 *

Callers 14

BranchManagerClass · 0.90
on_destroyMethod · 0.90
destroy_effectsFunction · 0.90
#handle_errorMethod · 0.90
attribute_effectFunction · 0.90
attachFunction · 0.90
destroy_derived_effectsFunction · 0.90
wrapperFunction · 0.90
create_effectFunction · 0.85
effect_rootFunction · 0.85
component_rootFunction · 0.85
destroy_effect_childrenFunction · 0.85

Calls 5

remove_reactionsFunction · 0.90
remove_effect_domFunction · 0.85
destroy_effect_childrenFunction · 0.85
execute_effect_teardownFunction · 0.85
unlink_effectFunction · 0.85

Tested by

no test coverage detected