Skip to content

Commit 9f9ffd8

Browse files
authored
Merge pull request #202 from SgLy/fix-placeholder-remover
fix(core): placeholderHandler do not trigger properly
2 parents b599530 + 3215efc commit 9f9ffd8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

glass-easel/src/component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,9 @@ export class Component<
542542
const comp = Object.create(proto) as ComponentInstance<TData, TProperty, TMethod>
543543
if (ENV.DEV) performanceMeasureStart('component.create', comp)
544544
comp._$genericImpls = genericImpls
545-
comp._$placeholderHandlerRemover = placeholderHandlerRemover
546545
comp._$external = external
547546
comp.tagName = tagName
548547
comp._$methodCaller = comp
549-
comp._$virtual = virtualHost
550548

551549
// check shared style scope
552550
const ownerSpace = behavior.ownerSpace
@@ -601,6 +599,7 @@ export class Component<
601599
owner,
602600
owner ? owner._$nodeTreeContext : nodeTreeContext!,
603601
)
602+
comp._$placeholderHandlerRemover = placeholderHandlerRemover
604603

605604
const ownerHost = owner ? owner.getHostNode() : undefined
606605
const ownerComponentOptions = ownerHost?.getComponentOptions()

glass-easel/src/component_space.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ export class ComponentWaitingList {
108108
}
109109

110110
call(c: GeneralComponentDefinition) {
111-
const cbs = this._$callbacks
112-
this._$callbacks = []
113-
for (let i = 0; i < cbs.length; i += 1) {
114-
const f = cbs[i]!
115-
f(c)
111+
while (this._$callbacks.length > 0) {
112+
const callback = this._$callbacks.shift()!
113+
callback(c)
116114
}
117115
}
118116
}

glass-easel/src/element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ export class Element implements NodeCast {
577577
node.triggerLifetime('beforeDetach', [])
578578
}
579579
node.childNodes.forEach(callFunc)
580-
const f = node._$placeholderHandlerRemover
581-
if (typeof f === 'function') f()
582580
if (isComponent(node)) {
583581
const shadowRoot = node.getShadowRoot()
584582
if (shadowRoot) callFunc(shadowRoot)
@@ -624,6 +622,8 @@ export class Element implements NodeCast {
624622
elem._$destroyOnRemoval = AutoDestroyState.Destroyed
625623
elem.destroyBackendElement()
626624
}
625+
const f = elem._$placeholderHandlerRemover
626+
if (typeof f === 'function') f()
627627
}
628628
rec(node)
629629
} else if (node._$destroyOnRemoval === AutoDestroyState.Enabled) {

0 commit comments

Comments
 (0)