-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
fix: detach error when node is not attached to DOM #3156
Conversation
Thanks. I think this is working around the issue rather than solving it though — I think it's better to identify the root causes. In this case, it seems that |
@Rich-Harris I agree that it's better to find the root cause. I think this guard is important in addition because this same exception has re-occurred whenever there has been a race condition or issue with detaching nodes. As discussed in the #updates discord channel, I didn't add a warning because I was not sure if the upstream cause of this error is a legitimate issue so I opted to keep it simple. Should there be a warning if |
@Rich-Harris There's a few more reasons to use the conditional in
|
I guess it makes sense to have the conditional in Perhaps as a compromise, we can log something scary sounding ('if you aren't messing with the DOM in some other way, this shouldn't happen', except scarier) if there's no parent node and we're compiling in dev mode? |
Svelte is already pretty forgiving when it comes to using third-party libraries that interact with the DOM, i don't know if it makes sense to cater to them directly. |
I'm not asking svelte to spend time catering to any library, though it's a bonus if Svelte is interoperable with other libraries. As somebody who uses Svelte, I've run into this bug before (internal to Svelte & not caused by outside code) & it resulted in a blank screen & I was unable to reproduce the issue in the repl. It's also difficult to reason about, the stack trace does not lead to the source of the problem (so a binary search of commenting out component logic is necessary to locate the offending code), & leaves the programmer with less confidence in using Svelte. This issue will come up again & rather than wasting everybody's time with the bug report, reproduction, discussion, we should remove the possibility of it appearing again. This fix even saves code. Rather than generating |
@Conduitry I see your point re: this exception (or warning) providing a cue that something occurred that should not have occurred. I just wonder if one of the core purposes of Svelte is to ensure that To your point, the warning could occur "You or another library should not manually remove a DOM element" Other than |
To prevent further forking of this discussion, I'd like to point out that it's been moved to #3172 |
#2086
Credit to @ciri #2086 (comment)