Ref added strict null checking for parentElement

This commit is contained in:
Lorenzo Iovino 2024-01-09 23:49:56 +01:00
parent f62bbf7d36
commit 95adc815fc

View file

@ -143,13 +143,13 @@ export class Ng2FittextDirective
getStartFontSizeFromHeight(): number { getStartFontSizeFromHeight(): number {
return this.container return this.container
? this.container.clientHeight ? this.container.clientHeight
: this.el.nativeElement.parentElement.clientHeight; : this.el.nativeElement.parentElement!.clientHeight;
} }
private getStartFontSizeFromWeight(): number { private getStartFontSizeFromWeight(): number {
return this.container return this.container
? this.container.clientWidth ? this.container.clientWidth
: this.el.nativeElement.parentElement.clientWidth; : this.el.nativeElement.parentElement!.clientWidth;
} }
isDone(): boolean { isDone(): boolean {
@ -164,7 +164,7 @@ export class Ng2FittextDirective
return this.container return this.container
? this.checkOverflow(this.container, this.el.nativeElement) ? this.checkOverflow(this.container, this.el.nativeElement)
: this.checkOverflow( : this.checkOverflow(
this.el.nativeElement.parentElement, this.el.nativeElement.parentElement!,
this.el.nativeElement this.el.nativeElement
); );
} }