From 771824ded2c29ed3c66b6fd62a9c08918ebc2a7c Mon Sep 17 00:00:00 2001 From: "v.potekhin" Date: Thu, 23 Nov 2023 11:46:06 +0300 Subject: [PATCH] chore: comments --- .../ng-polymorpheus/src/directives/outlet.ts | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/projects/ng-polymorpheus/src/directives/outlet.ts b/projects/ng-polymorpheus/src/directives/outlet.ts index b3712e96..192ef70b 100644 --- a/projects/ng-polymorpheus/src/directives/outlet.ts +++ b/projects/ng-polymorpheus/src/directives/outlet.ts @@ -51,22 +51,20 @@ export class PolymorpheusOutletDirective implements OnChanges, DoCheck { this.vcr.clear(); + const proxy = + context && + (new Proxy(context as object, { + get: (_, key) => + this.getContext()?.[key as keyof (C | PolymorpheusContext)], + }) as unknown as C); + if (isComponent(this.content)) { - this.process(this.content); + this.process(this.content, proxy); } else if ( // tslint:disable-next-line:triple-equals (context instanceof PolymorpheusContext && context.$implicit) != null ) { - this.vcr.createEmbeddedView( - this.template, - context && - (new Proxy(context as object, { - get: (_, key) => - this.getContext()?.[ - key as keyof (C | PolymorpheusContext) - ], - }) as unknown as C), - ); + this.vcr.createEmbeddedView(this.template, proxy); } } @@ -95,14 +93,8 @@ export class PolymorpheusOutletDirective implements OnChanges, DoCheck { ); } - private process(content: PolymorpheusComponent): void { - const injector = content.createInjector( - this.i, - this.context && - (new Proxy(this.context as unknown as object, { - get: (_, key) => this.context?.[key as keyof C], - }) as unknown as C), - ); + private process(content: PolymorpheusComponent, proxy?: C): void { + const injector = content.createInjector(this.i, proxy); this.c = this.vcr.createComponent( injector