Skip to content

Commit d97d48d

Browse files
committed
fix(core): adjust removeChild logic to get THREE parent first before getting renderer parent
1 parent 5f1a36d commit d97d48d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libs/core/src/lib/renderer/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,22 @@ export class NgtRenderer implements Renderer2 {
281281
}
282282

283283
removeChild(parent: NgtRendererNode, oldChild: NgtRendererNode, isHostElement?: boolean | undefined): void {
284-
if (parent === null) {
285-
parent = (oldChild.__ngt_renderer__[NgtRendererClassId.parent] ||
286-
untracked(() => getLocalState(oldChild)?.parent)) as NgtRendererNode;
284+
if (parent == null) {
285+
parent = (untracked(() => getLocalState(oldChild)?.parent) ||
286+
oldChild.__ngt_renderer__[NgtRendererClassId.parent]) as NgtRendererNode;
287287
}
288288

289+
const cRS = oldChild.__ngt_renderer__;
290+
289291
// if parent is still falsy, we don't know what to do with the parent.
290292
// we'll just remove the child and destroy it
291-
if (!parent) {
293+
if (parent == null && cRS?.[NgtRendererClassId.type] !== 'three') {
292294
removeThreeChild(oldChild, undefined, true);
293295
this.destroyInternal(oldChild, undefined);
294296
return;
295297
}
296298

297299
const pRS = parent.__ngt_renderer__;
298-
const cRS = oldChild.__ngt_renderer__;
299300

300301
if (
301302
(!cRS || !pRS) &&

0 commit comments

Comments
 (0)