From 189593e5a096c333ef8acea6cd78bb6b4066e7bd Mon Sep 17 00:00:00 2001 From: SgLy <775150558@qq.com> Date: Fri, 25 Aug 2023 17:37:40 +0800 Subject: [PATCH] fix(core): destroy backend element on detached before recursing into children --- glass-easel/src/element.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glass-easel/src/element.ts b/glass-easel/src/element.ts index 9438c19..941bfe6 100644 --- a/glass-easel/src/element.ts +++ b/glass-easel/src/element.ts @@ -405,6 +405,9 @@ export class Element implements NodeCast { private static checkAndCallDetached(node: Node) { const callFunc = function callFunc(node: Node) { + if (node._$destroyOnDetach) { + node.destroyBackendElement() + } if (node instanceof Element && node._$attached) { node.childNodes.forEach(callFunc) if (node instanceof Component) { @@ -430,9 +433,6 @@ export class Element implements NodeCast { node._$attached = false } } - if (node._$destroyOnDetach) { - node.destroyBackendElement() - } } callFunc(node) }