-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Cannot properly destroy component after changing slotted node #5879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The text is a node on its own and rewriting Svelte cannot workaround the user replacing nodes, it could at best in dev mode warn that the node went missing For your specific use case you can get the node reference by calling |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing this due to #6910 which silences the error - that said, as pointed out manual manipulation of the DOM is almost always the wrong solution and can lead to errors like this. Svelte should be in control of manipulating the DOM. |
Describe the bug
Components are unable to destroy properly when component contains a slot whose text was changed via node.textContext. Please refer to REPL link below for repro. This bug/error can prevent further interaction with the Svelte app.
Logs
After destroying component, Svelte throws the following error:
To Reproduce
https://svelte.dev/repl/f9cc573c14a943098f68964dc5496fd7?version=3.31.2
Expected behavior
This may be an expected behavior of the current version of Svelte, but ideally I would be able to manipulate the DOM within a component and still destroy components in the usual Svelte-y way.
Stacktraces
If you have a stack trace to include, we recommend putting inside a
<details>
block for the sake of the thread's readability:Stack trace
Uncaught (in promise) TypeError: Cannot read property 'removeChild' of null
at detach (eval at handle_message (VM950 about:srcdoc:13), :81:25)
at detach_dev (eval at handle_message (VM950 about:srcdoc:13), :344:9)
at Object.destroy [as d] (eval at handle_message (VM950 about:srcdoc:13), :594:23)
at Object.destroy [as d] (eval at handle_message (VM950 about:srcdoc:13), :455:39)
at destroy_component (eval at handle_message (VM950 about:srcdoc:13), :235:40)
at Object.destroy [as d] (eval at handle_message (VM950 about:srcdoc:13), :567:8)
at eval (eval at handle_message (VM950 about:srcdoc:13), :203:31)
at run (eval at handle_message (VM950 about:srcdoc:13), :24:16)
at Array.forEach ()
at run_all (eval at handle_message (VM950 about:srcdoc:13), :30:13)
detach @ VM953:81
detach_dev @ VM953:344
destroy @ VM953:594
destroy @ VM953:455
destroy_component @ VM953:235
destroy @ VM953:567
eval @ VM953:203
run @ VM953:24
run_all @ VM953:30
check_outros @ VM953:184
update @ VM953:696
update @ VM953:169
flush @ VM953:137
Promise.then (async)
schedule_update @ VM953:119
make_dirty @ VM953:245
eval @ VM953:281
click_handler @ VM953:745
Information about your Svelte project:
This is my dev env (but this also happen on [email protected]):
Severity
How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Svelte entirely?
The bug itself is game-breaking, triggering the bug will stop some, if not all, of the Svelte app. I've refactored to not use slots and to pass in as a variable instead, so at worst the code readability drops a little bit, but there may be more complex/necessary use cases that would be implicated by this bug that I haven't considered.
The text was updated successfully, but these errors were encountered: