-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Trying to wrap my head round this while looking at #1117. I don't think ondestroy
should be called for a custom element when it's detached (with disconnectedCallback
) because it means something slightly different in custom element land — it can be a temporary thing (the element can be reinserted), whereas destroy
is permanent. In other words, destroy
should still be called manually for custom elements inserted with e.g. document.body.innerHTML = '<x-app/>'
.
But when we have a situation like this...
{{#if foo}}
<x-thing/>
{{/if}}
...and x-thing
is a Svelte custom element, we probably do want to call ondestroy
, since there's basically no sensible way to do that programmatically.
Which means we need a reliable way to distinguish between Svelte custom elements and non-Svelte custom elements (where destroy
could potentially mean something different, meaning duck typing isn't necessarily reliable).