Skip to content

Commit 1bab571

Browse files
authored
fix: additional check for component on destroy (svelte4) (#11489)
fixes #10454
1 parent 0919128 commit 1bab571

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/many-trainers-pretend.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: check if svelte component exists on custom element destroy

packages/svelte/src/runtime/internal/Component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ if (typeof HTMLElement === 'function') {
335335
this.$$cn = false;
336336
// In a microtask, because this could be a move within the DOM
337337
Promise.resolve().then(() => {
338-
if (!this.$$cn) {
338+
if (!this.$$cn && this.$$c) {
339339
this.$$c.$destroy();
340340
this.$$c = undefined;
341341
}

0 commit comments

Comments
 (0)