Skip to content

Commit 911e518

Browse files
committed
refactor(elements): simplify setInputValue override componentRef checks
1 parent 27c9f0a commit 911e518

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

projects/igniteui-angular-elements/src/app/custom-strategy.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,21 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
257257
}
258258

259259
public override setInputValue(property: string, value: any): void {
260-
if (this._componentRef === null ||
261-
!this._componentRef.instance) {
260+
if (this._componentRef === null || !this._componentRef.instance) {
262261
this._initialInputValues.set(property, value);
263262
return;
264263
}
265-
const componentRef = this._componentRef;
266-
const componentConfig = this.config?.find(x => x.component === this._componentFactory.componentType);
267264

268-
if (value === componentRef.instance[property]) {
265+
if (value === this._componentRef.instance[property]) {
269266
return;
270267
}
271-
if (componentRef && componentConfig?.templateProps?.includes(property)) {
268+
269+
const componentConfig = this.config?.find(x => x.component === this._componentFactory.componentType);
270+
271+
if (componentConfig?.templateProps?.includes(property)) {
272272
// const oldValue = this.getInputValue(property);
273273
if (this.templateWrapper.templateFunctions.includes(value)) return;
274-
const oldRef = componentRef.instance[property];
274+
const oldRef = this._componentRef.instance[property];
275275
const oldValue = oldRef && this.templateWrapper.getTemplateFunction(oldRef);
276276
if (oldValue === value) {
277277
return;
@@ -280,18 +280,18 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
280280
// TODO: discard oldValue
281281

282282
// check template for any angular-element components
283-
this.templateWrapper.templateRendered.pipe(takeUntilDestroyed(componentRef.injector.get(DestroyRef))).subscribe((element) => {
283+
this.templateWrapper.templateRendered.pipe(takeUntilDestroyed(this._componentRef.injector.get(DestroyRef))).subscribe((element) => {
284284
element.querySelectorAll<IgcNgElement>(this.configSelectors)?.forEach((c) => {
285285
// tie to angularParent lifecycle for cached scenarios like detailTemplate:
286-
c.ngElementStrategy.angularParent = componentRef;
286+
c.ngElementStrategy.angularParent = this._componentRef;
287287
});
288288
});
289289
}
290-
if (componentRef && componentConfig?.boolProps?.includes(property)) {
290+
if (componentConfig?.boolProps?.includes(property)) {
291291
// bool coerce:
292292
value = value != null && `${value}` !== 'false';
293293
}
294-
if (componentRef && componentConfig?.numericProps?.includes(property)) {
294+
if (componentConfig?.numericProps?.includes(property)) {
295295
// number coerce:
296296
if (!isNaN(Number(value) - parseFloat(value))) {
297297
value = Number(value);

0 commit comments

Comments
 (0)