Skip to content

Commit

Permalink
fix: additional check for component on destroy (svelte4) (#11489)
Browse files Browse the repository at this point in the history
fixes #10454
  • Loading branch information
hardl authored May 6, 2024
1 parent 0919128 commit 1bab571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/many-trainers-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: check if svelte component exists on custom element destroy
2 changes: 1 addition & 1 deletion packages/svelte/src/runtime/internal/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ if (typeof HTMLElement === 'function') {
this.$$cn = false;
// In a microtask, because this could be a move within the DOM
Promise.resolve().then(() => {
if (!this.$$cn) {
if (!this.$$cn && this.$$c) {
this.$$c.$destroy();
this.$$c = undefined;
}
Expand Down

0 comments on commit 1bab571

Please sign in to comment.