@pepperi-addons/ngx-lib 0.4.2-beta.316 → 0.4.2-beta.318

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -906,24 +906,33 @@ class PepInputAutoWidthDirective {
906
906
  this.el = el;
907
907
  this.includePadding = true;
908
908
  this.input = null;
909
+ this.onBlurHandler = () => this.setWidthUsingText();
910
+ this.onKeyupHandler = () => this.setWidthUsingText();
909
911
  }
910
912
  ngAfterViewInit() {
911
- if (this.el.nativeElement.tagName.toLowerCase() === 'input') {
912
- this.input = this.el;
913
+ var _a, _b, _c;
914
+ if (((_b = (_a = this.el.nativeElement) === null || _a === void 0 ? void 0 : _a.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'input') {
915
+ this.input = this.el.nativeElement;
913
916
  }
914
917
  else {
915
- const list = this.el.nativeElement.querySelectorAll('input');
916
- this.input = list.length > 0 ? list[0] : null;
918
+ const list = ((_c = this.el.nativeElement) === null || _c === void 0 ? void 0 : _c.querySelectorAll)
919
+ ? this.el.nativeElement.querySelectorAll('input')
920
+ : null;
921
+ this.input = list && list.length > 0 ? list[0] : null;
917
922
  }
918
923
  if (this.input) {
919
- this.input.addEventListener('blur', this.setWidthUsingText.bind(this));
920
- this.input.addEventListener('keyup', this.setWidthUsingText.bind(this));
924
+ this.input.addEventListener('blur', this.onBlurHandler);
925
+ this.input.addEventListener('keyup', this.onKeyupHandler);
921
926
  }
922
927
  this.setWidthUsingText();
923
928
  }
924
929
  ngOnDestroy() {
925
- this.input.removeEventListener('blur', this.setWidthUsingText.bind(this));
926
- this.input.removeEventListener('keyup', this.setWidthUsingText.bind(this));
930
+ if (!this.input) {
931
+ return;
932
+ }
933
+ this.input.removeEventListener('blur', this.onBlurHandler);
934
+ this.input.removeEventListener('keyup', this.onKeyupHandler);
935
+ this.input = null;
927
936
  }
928
937
  get paddingWidth() {
929
938
  return this.includePadding