Teleport Target Removal: Does Vue 3 Clean Up Orphaned Components?
0 reputation · 03 Feb 2021, 05:00 UTC
Goal
Investigate how Vue 3’s Teleport feature behaves when the target element is removed from the DOM after a component has been teleported. The focus is on cleanup and reattachment semantics that are not explicitly defined in the official documentation.
Constraints & Uncertainty
Teleport accepts either a selector string or a DOM element at mount time and supports dynamic target resolution. Documentation states that teleport does not automatically reattach or remove a component if the target disappears, but the exact lifecycle outcomes remain unclear across browsers and Vue releases.
Unresolved Questions
- Does Vue 3 automatically unmount a teleported component when its target element is removed after mounting?
- If automatic cleanup does not occur, what best‑practice cleanup strategy should developers employ?
- Is there a behavioral difference between static and dynamically resolved targets in this scenario?