From c1fdece024a01ebe32a3db7f872088dd821c57d2 Mon Sep 17 00:00:00 2001 From: SgLy <775150558@qq.com> Date: Mon, 21 Oct 2024 19:14:39 +0800 Subject: [PATCH 1/2] fix(core): placeholderHandler do not trigger properly --- glass-easel/src/component.ts | 3 +-- glass-easel/src/component_space.ts | 8 +++----- glass-easel/src/element.ts | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/glass-easel/src/component.ts b/glass-easel/src/component.ts index 1722bad..3603795 100644 --- a/glass-easel/src/component.ts +++ b/glass-easel/src/component.ts @@ -542,11 +542,9 @@ export class Component< const comp = Object.create(proto) as ComponentInstance if (ENV.DEV) performanceMeasureStart('component.create', comp) comp._$genericImpls = genericImpls - comp._$placeholderHandlerRemover = placeholderHandlerRemover comp._$external = external comp.tagName = tagName comp._$methodCaller = comp - comp._$virtual = virtualHost // check shared style scope const ownerSpace = behavior.ownerSpace @@ -601,6 +599,7 @@ export class Component< owner, owner ? owner._$nodeTreeContext : nodeTreeContext!, ) + comp._$placeholderHandlerRemover = placeholderHandlerRemover const ownerHost = owner ? owner.getHostNode() : undefined const ownerComponentOptions = ownerHost?.getComponentOptions() diff --git a/glass-easel/src/component_space.ts b/glass-easel/src/component_space.ts index 3edeaf5..41e37b4 100644 --- a/glass-easel/src/component_space.ts +++ b/glass-easel/src/component_space.ts @@ -108,11 +108,9 @@ export class ComponentWaitingList { } call(c: GeneralComponentDefinition) { - const cbs = this._$callbacks - this._$callbacks = [] - for (let i = 0; i < cbs.length; i += 1) { - const f = cbs[i]! - f(c) + while (this._$callbacks.length > 0) { + const callback = this._$callbacks.shift()! + callback(c) } } } diff --git a/glass-easel/src/element.ts b/glass-easel/src/element.ts index 3df4ed2..01211a3 100644 --- a/glass-easel/src/element.ts +++ b/glass-easel/src/element.ts @@ -577,8 +577,6 @@ export class Element implements NodeCast { node.triggerLifetime('beforeDetach', []) } node.childNodes.forEach(callFunc) - const f = node._$placeholderHandlerRemover - if (typeof f === 'function') f() if (isComponent(node)) { const shadowRoot = node.getShadowRoot() if (shadowRoot) callFunc(shadowRoot) @@ -623,6 +621,8 @@ export class Element implements NodeCast { if (elem._$destroyOnRemoval === AutoDestroyState.Enabled) { elem._$destroyOnRemoval = AutoDestroyState.Destroyed elem.destroyBackendElement() + const f = elem._$placeholderHandlerRemover + if (typeof f === 'function') f() } } rec(node) From 3215efc53e0bfa775b3cd77d83e9fa493f219424 Mon Sep 17 00:00:00 2001 From: SgLy <775150558@qq.com> Date: Mon, 21 Oct 2024 20:34:12 +0800 Subject: [PATCH 2/2] fix(core): placeholderHandler do not trigger properly --- glass-easel/src/element.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glass-easel/src/element.ts b/glass-easel/src/element.ts index 01211a3..2728a56 100644 --- a/glass-easel/src/element.ts +++ b/glass-easel/src/element.ts @@ -621,9 +621,9 @@ export class Element implements NodeCast { if (elem._$destroyOnRemoval === AutoDestroyState.Enabled) { elem._$destroyOnRemoval = AutoDestroyState.Destroyed elem.destroyBackendElement() - const f = elem._$placeholderHandlerRemover - if (typeof f === 'function') f() } + const f = elem._$placeholderHandlerRemover + if (typeof f === 'function') f() } rec(node) } else if (node._$destroyOnRemoval === AutoDestroyState.Enabled) {