Skip to content

Commit 3e1f82b

Browse files
authored
fix: additional check for component on destroy (#11488)
fixes #10454
1 parent fa3e98e commit 3e1f82b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/olive-apples-lick.md

Lines changed: 5 additions & 0 deletions
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/internal/client/dom/elements/custom-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ if (typeof HTMLElement === 'function') {
193193
this.$$cn = false;
194194
// In a microtask, because this could be a move within the DOM
195195
Promise.resolve().then(() => {
196-
if (!this.$$cn) {
196+
if (!this.$$cn && this.$$c) {
197197
this.$$c.$destroy();
198198
destroy_effect(this.$$me);
199199
this.$$c = undefined;

0 commit comments

Comments
 (0)