Fix CheckButton causing 'cannot read properties of undefined' on Edge

This commit is contained in:
Andrio Celos 2023-01-10 20:05:17 +11:00
parent c809e19e06
commit c082077660
4 changed files with 6 additions and 6 deletions

View File

@ -86,7 +86,7 @@ class CardButton {
el2.appendChild(el3);
}
this.button = new CheckButton(checkBox);
this.button = new CheckButton(checkBox, el);
CardButton.idNumber++;
}

View File

@ -2,9 +2,9 @@ class CheckButton {
readonly input: HTMLInputElement;
readonly label: HTMLLabelElement;
constructor(input: HTMLInputElement) {
constructor(input: HTMLInputElement, label?: HTMLLabelElement) {
this.input = input;
this.label = input.labels![0];
this.label = label ?? input.labels![0];
this.input.addEventListener('input', () => {
this.checked = this.input.checked;
});
@ -29,4 +29,4 @@ class CheckButton {
else
this.label.classList.remove('checked');
}
}
}

View File

@ -99,7 +99,7 @@ function createDeckButton(index: number, deck: Deck) {
label.appendChild(document.createTextNode(deck.name));
deckList.insertBefore(label, addDeckControls);
deckButtons.push(new CheckButton(input));
deckButtons.push(new CheckButton(input, label));
return label;
}

View File

@ -144,7 +144,7 @@ function initDeckSelection() {
label.appendChild(document.createTextNode(deck.name));
lobbyDeckList.appendChild(label);
const button = new CheckButton(input);
const button = new CheckButton(input, label);
lobbyDeckButtons.push(button);
if (!deck.isValid) {