fix(js): use on
instead of addEventListener
to ensure cleanup
This commit is contained in:
parent
d16c490779
commit
5ccf57b488
2 changed files with 6 additions and 6 deletions
|
@ -21,7 +21,7 @@ export class ReplaceAttachmentController extends ApplicationController {
|
||||||
|
|
||||||
// reset autoAttachUrl which would add an attachment
|
// reset autoAttachUrl which would add an attachment
|
||||||
// when replace is not finalized
|
// when replace is not finalized
|
||||||
this.inputTarget.addEventListener('cancel', () => {
|
this.on(this.inputTarget, 'cancel', () => {
|
||||||
this.inputTarget.dataset.autoAttachUrl =
|
this.inputTarget.dataset.autoAttachUrl =
|
||||||
this.inputTarget.dataset.originalAutoAttachUrl;
|
this.inputTarget.dataset.originalAutoAttachUrl;
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,12 +9,12 @@ export class SupportController extends ApplicationController {
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
this.inputRadioTargets.forEach((inputRadio) => {
|
this.inputRadioTargets.forEach((inputRadio) => {
|
||||||
inputRadio.addEventListener('change', this.onChange.bind(this));
|
this.on(inputRadio, 'change', this.onChange.bind(this));
|
||||||
inputRadio.addEventListener('keydown', this.onChange.bind(this));
|
this.on(inputRadio, 'keydown', this.onChange.bind(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(event: Event) {
|
private onChange(event: Event) {
|
||||||
const target = event.target as HTMLInputElement;
|
const target = event.target as HTMLInputElement;
|
||||||
const content = this.getContentForTarget(target);
|
const content = this.getContentForTarget(target);
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ export class SupportController extends ApplicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getLabelForTarget(target: HTMLInputElement) {
|
private getLabelForTarget(target: HTMLInputElement) {
|
||||||
const labelSelector = `label[for="${target.id}"]`;
|
const labelSelector = `label[for="${target.id}"]`;
|
||||||
return document.querySelector(labelSelector);
|
return document.querySelector(labelSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
getContentForTarget(target: HTMLInputElement) {
|
private getContentForTarget(target: HTMLInputElement) {
|
||||||
const label = this.getLabelForTarget(target);
|
const label = this.getLabelForTarget(target);
|
||||||
if (!label) {
|
if (!label) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue