Skip to content

Commit fb2016c

Browse files
committed
refactor(core): do not repeat the same obj in portal
1 parent 5261509 commit fb2016c

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ Thumbs.db
4747
vite.config.*.timestamp*
4848
vitest.config.*.timestamp*
4949
.aider*
50+
CLAUDE.md

libs/core/src/lib/portal.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export class NgtPortalContent {
9191
constructor() {
9292
const host = inject<ElementRef<HTMLElement>>(ElementRef, { skipSelf: true });
9393
const { element } = inject(ViewContainerRef);
94-
const injector = inject(Injector);
9594
const commentNode = element.nativeElement;
9695
const store = injectStore();
9796

@@ -246,11 +245,8 @@ export class NgtPortalImpl {
246245
return;
247246
}
248247

249-
this.portalViewRef = anchor.createEmbeddedView(
250-
content,
251-
{ injector: this.injector },
252-
{ injector: this.injector },
253-
);
248+
const portalViewContext = { injector: this.injector };
249+
this.portalViewRef = anchor.createEmbeddedView(content, portalViewContext, portalViewContext);
254250
this.portalViewRef.detectChanges();
255251
this.portalContentRendered.set(true);
256252
});

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,7 @@ export class NgtRenderer2 implements Renderer2 {
697697
const cleanup = iS.setPointerEvent?.(eventName as keyof NgtEventHandlers, callback) || (() => {});
698698

699699
// this means the object has already been attached to the parent and has its store propagated
700-
if (iS.store) {
701-
iS.addInteraction?.(iS.store);
702-
}
700+
if (iS.store) iS.addInteraction?.(iS.store);
703701

704702
return cleanup;
705703
}

0 commit comments

Comments
 (0)