Skip to content

Commit 04fffae

Browse files
committed
fix: adjust how children of portal store gets the portalStore instance
1 parent baba2d8 commit 04fffae

File tree

1 file changed

+8
-4
lines changed
  • libs/angular-three/src/lib/renderer

1 file changed

+8
-4
lines changed

libs/angular-three/src/lib/renderer/state.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,18 @@ export class NgtRendererStore {
6767
state[NgtRendererClassId.injectorFactory] = () => getDebugNode(rendererNode)!.injector;
6868
// we attach an arrow function to the Comment node
6969
// In our directives, we can call this function to then start tracking the RendererNode
70-
rendererNode['__ngt_renderer_add_comment__'] = () => {
71-
this.comments.push(rendererNode);
70+
rendererNode['__ngt_renderer_add_comment__'] = (portalNode?: NgtRendererNode) => {
71+
if (portalNode && portalNode.__ngt_renderer__[NgtRendererClassId.type] === 'portal') {
72+
this.portals.push(portalNode);
73+
} else {
74+
this.comments.push(rendererNode);
75+
}
7276
};
7377
return rendererNode;
7478
}
7579

7680
if (state[NgtRendererClassId.type] === 'portal') {
7781
state[NgtRendererClassId.injectorFactory] = () => getDebugNode(rendererNode)!.injector;
78-
this.portals.push(rendererNode);
7982
return rendererNode;
8083
}
8184

@@ -426,7 +429,8 @@ export class NgtRendererStore {
426429
continue;
427430
}
428431
const instance = injector.get(NgtStore, null);
429-
if (instance) {
432+
// only the instance with previousStore should pass
433+
if (instance && instance.get('previousStore')) {
430434
store = instance;
431435
break;
432436
}

0 commit comments

Comments
 (0)