Skip to content

Commit

Permalink
fix(core): adjust removeChild logic to get THREE parent first before …
Browse files Browse the repository at this point in the history
…getting renderer parent
  • Loading branch information
nartc committed Aug 13, 2024
1 parent 5f1a36d commit d97d48d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libs/core/src/lib/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,22 @@ export class NgtRenderer implements Renderer2 {
}

removeChild(parent: NgtRendererNode, oldChild: NgtRendererNode, isHostElement?: boolean | undefined): void {
if (parent === null) {
parent = (oldChild.__ngt_renderer__[NgtRendererClassId.parent] ||
untracked(() => getLocalState(oldChild)?.parent)) as NgtRendererNode;
if (parent == null) {
parent = (untracked(() => getLocalState(oldChild)?.parent) ||
oldChild.__ngt_renderer__[NgtRendererClassId.parent]) as NgtRendererNode;
}

const cRS = oldChild.__ngt_renderer__;

// if parent is still falsy, we don't know what to do with the parent.
// we'll just remove the child and destroy it
if (!parent) {
if (parent == null && cRS?.[NgtRendererClassId.type] !== 'three') {
removeThreeChild(oldChild, undefined, true);
this.destroyInternal(oldChild, undefined);
return;
}

const pRS = parent.__ngt_renderer__;
const cRS = oldChild.__ngt_renderer__;

if (
(!cRS || !pRS) &&
Expand Down

0 comments on commit d97d48d

Please sign in to comment.