Fix how radio 'checked' properties are set.
This commit is contained in:
@@ -179,7 +179,7 @@ function getInputValue(id: string) {
|
||||
}
|
||||
|
||||
function setRadioValue(name: string, value: string) {
|
||||
const radios = document.querySelectorAll(`[name="${name}"]`);
|
||||
const radios = document.querySelectorAll(`[name="${name}"]`) as NodeListOf<HTMLInputElement>;
|
||||
if (!radios) {
|
||||
throw new Error(`No radios with name "${name}"!`);
|
||||
}
|
||||
@@ -187,11 +187,11 @@ function setRadioValue(name: string, value: string) {
|
||||
if (!('value' in radio)) {
|
||||
throw new Error('Radio option does not have "value" attribute!');
|
||||
}
|
||||
radio.removeAttribute('checked');
|
||||
radio.checked = false;
|
||||
})
|
||||
const option = ([...radios] as HTMLInputElement[]).find(x => x.value);
|
||||
const option = Array.from(radios).find(x => x.value);
|
||||
if (!option) {
|
||||
throw new Error(`No option with value "${value}"`);
|
||||
}
|
||||
option.setAttribute('checked', '');
|
||||
option.checked = true;
|
||||
}
|
||||
Reference in New Issue
Block a user