diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts
index 6d211dfedd..0078b78c04 100644
--- a/src/runtime/internal/Component.ts
+++ b/src/runtime/internal/Component.ts
@@ -184,6 +184,10 @@ if (typeof HTMLElement === 'function') {
this[attr] = newValue;
}
+ disconnectedCallback() {
+ this.$destroy();
+ }
+
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
diff --git a/test/custom-elements/samples/ondestroy/main.svelte b/test/custom-elements/samples/ondestroy/main.svelte
new file mode 100644
index 0000000000..aa945ca602
--- /dev/null
+++ b/test/custom-elements/samples/ondestroy/main.svelte
@@ -0,0 +1,22 @@
+