Skip to content

Commit

Permalink
Merge pull request #202 from SgLy/fix-placeholder-remover
Browse files Browse the repository at this point in the history
fix(core): placeholderHandler do not trigger properly
  • Loading branch information
LastLeaf authored Oct 22, 2024
2 parents b599530 + 3215efc commit 9f9ffd8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions glass-easel/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,9 @@ export class Component<
const comp = Object.create(proto) as ComponentInstance<TData, TProperty, TMethod>
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
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 3 additions & 5 deletions glass-easel/src/component_space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions glass-easel/src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -624,6 +622,8 @@ export class Element implements NodeCast {
elem._$destroyOnRemoval = AutoDestroyState.Destroyed
elem.destroyBackendElement()
}
const f = elem._$placeholderHandlerRemover
if (typeof f === 'function') f()
}
rec(node)
} else if (node._$destroyOnRemoval === AutoDestroyState.Enabled) {
Expand Down

0 comments on commit 9f9ffd8

Please sign in to comment.