(effect, remove_dom = true)
| 509 | * @returns {void} |
| 510 | */ |
| 511 | export 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 | * |
no test coverage detected