@@ -281,7 +281,17 @@ export class NgtRenderer implements Renderer2 {
281
281
this . appendChild ( parent , newChild ) ;
282
282
}
283
283
284
- removeChild ( parent : NgtRendererNode | null , oldChild : NgtRendererNode , isHostElement ?: boolean | undefined ) : void {
284
+ removeChild (
285
+ parent : NgtRendererNode | null ,
286
+ oldChild : NgtRendererNode ,
287
+ isHostElement ?: boolean | undefined ,
288
+ calledByNgt = false ,
289
+ ) : void {
290
+ if ( ! calledByNgt && parent == null ) {
291
+ parent = this . parentNode ( oldChild ) ;
292
+ return this . removeChild ( parent , oldChild , isHostElement , true ) ;
293
+ }
294
+
285
295
if ( parent == null ) {
286
296
parent = ( untracked ( ( ) => getLocalState ( oldChild ) ?. parent ?.( ) ) ||
287
297
oldChild . __ngt_renderer__ ?. [ NgtRendererClassId . parent ] ) as NgtRendererNode ;
@@ -293,13 +303,13 @@ export class NgtRenderer implements Renderer2 {
293
303
// we'll just remove the child and destroy it
294
304
if ( parent == null ) {
295
305
if ( cRS ) {
306
+ // if the child is the root scene, we don't want to destroy it
307
+ if ( is . scene ( oldChild ) && oldChild . name === '__ngt_root_scene__' ) return ;
308
+
296
309
if ( cRS [ NgtRendererClassId . type ] === 'three' ) {
297
310
removeThreeChild ( oldChild , undefined , true ) ;
298
311
}
299
312
300
- // if the child is the root scene, we don't want to destroy it
301
- if ( is . scene ( oldChild ) && oldChild . name === '__ngt_root_scene__' ) return ;
302
-
303
313
// otherwise, we'll destroy it
304
314
this . destroyInternal ( oldChild , undefined ) ;
305
315
}
0 commit comments