-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the bug
Component rendering breaks after manually inserting a mount
ed component into one DOM node and then moving it into another.
I'm not sure if this sort of thing was ever officially supported. I haven't found anything in the docs. This pattern worked in 5.22.2 but broke in 5.22.3 (5 months ago) due to effect processing changes.
My exact use case is a complex "tiling window manager" component akin to GoldenLayout. The basic requirement is to preserve the exact DOM state of a component instance when it's conditionally rendered in different locations. The component contains complex internal state (form inputs, scroll position, third-party widget state, etc.) that can't be serialized/restored. I need the exact same component instance DOM to be reused rather than destroyed/recreated.
I've written a minimal reproduction below. Pressing the inc
button works as expected until the swap
button is pressed, then the inc
button stops working.
If this is an unsupported technique, any advice would be appreciated.
Reproduction
- https://svelte.dev/playground/6534c37164ee409d8c21fcb4ee58e91b?version=5.38.6 (fails)
- https://svelte.dev/playground/6534c37164ee409d8c21fcb4ee58e91b?version=5.22.3 (fails)
- https://svelte.dev/playground/6534c37164ee409d8c21fcb4ee58e91b?version=5.22.2 (works)
System Info
Binaries:
Node: 24.6.0
npm: 11.5.1
Browsers:
Chromium: 138.0.7204.183
npmPackages:
svelte: 5.38.6 => 5.38.6
Severity
blocking an upgrade, regression