diff --git a/djx/src/main/ts/tsx/traits.ts b/djx/src/main/ts/tsx/traits.ts --- a/djx/src/main/ts/tsx/traits.ts +++ b/djx/src/main/ts/tsx/traits.ts @@ -110,9 +110,9 @@ export function destroy(target: Node | I } else if (isDestroyable(target)) { target.destroy(); } else if (isNode(target)) { - const self = registry.byNode(target); - if (self) { - self.destroyRecursive(); + const w = isElementNode(target) ? registry.byNode(target) : undefined; + if (w) { + w.destroyRecursive(); } else { registry.findWidgets(target).forEach(destroy); dom.destroy(target);