Skip to content

Commit

Permalink
fix(core/validation-tooltip): prevent assignment/reading on null elem…
Browse files Browse the repository at this point in the history
…ent (#1001)
  • Loading branch information
jul-lam committed Jan 15, 2024
1 parent 3b60034 commit 813b882
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ export class ValidationTooltip {
}

get formElement() {
return this.inputElement.form;
return this.inputElement?.form;
}

get tooltipElement(): HTMLElement {
return this.hostElement.shadowRoot.querySelector('.validation-tooltip');
}

private destroyAutoUpdate() {
this.tooltipElement.style.display = 'none';
if (this.tooltipElement) {
this.tooltipElement.style.display = 'none';
}

if (this.autoUpdateCleanup) {
this.autoUpdateCleanup();
Expand Down Expand Up @@ -187,8 +189,8 @@ export class ValidationTooltip {
this.observer?.disconnect();
this.destroyAutoUpdate();

this.formElement.removeEventListener('submit', this.onSubmitBind);
this.inputElement.removeEventListener('focus', this.onInputFocusBind);
this.formElement?.removeEventListener('submit', this.onSubmitBind);
this.inputElement?.removeEventListener('focus', this.onInputFocusBind);
}

@Watch('isInputValid')
Expand Down

0 comments on commit 813b882

Please sign in to comment.