Fix how radio 'checked' properties are set.
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -4877,7 +4877,11 @@
|
|||||||
},
|
},
|
||||||
"packages/declaform": {
|
"packages/declaform": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC"
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"ajv": "^8.17.1",
|
||||||
|
"ajv-formats": "^3.0.1"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"packages/json-schema": {
|
"packages/json-schema": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ class Field {
|
|||||||
(this._inputs as HTMLInputElement[])
|
(this._inputs as HTMLInputElement[])
|
||||||
.forEach(input => {
|
.forEach(input => {
|
||||||
if (input.value === val) {
|
if (input.value === val) {
|
||||||
input.setAttribute('checked', '');
|
input.checked = true;
|
||||||
} else {
|
} else {
|
||||||
input.removeAttribute('checked');
|
input.checked = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ function getInputValue(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setRadioValue(name: string, value: string) {
|
function setRadioValue(name: string, value: string) {
|
||||||
const radios = document.querySelectorAll(`[name="${name}"]`);
|
const radios = document.querySelectorAll(`[name="${name}"]`) as NodeListOf<HTMLInputElement>;
|
||||||
if (!radios) {
|
if (!radios) {
|
||||||
throw new Error(`No radios with name "${name}"!`);
|
throw new Error(`No radios with name "${name}"!`);
|
||||||
}
|
}
|
||||||
@@ -187,11 +187,11 @@ function setRadioValue(name: string, value: string) {
|
|||||||
if (!('value' in radio)) {
|
if (!('value' in radio)) {
|
||||||
throw new Error('Radio option does not have "value" attribute!');
|
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) {
|
if (!option) {
|
||||||
throw new Error(`No option with value "${value}"`);
|
throw new Error(`No option with value "${value}"`);
|
||||||
}
|
}
|
||||||
option.setAttribute('checked', '');
|
option.checked = true;
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"types": [],
|
"types": [],
|
||||||
|
"lib": ["es2017", "dom"],
|
||||||
|
|
||||||
// Other Outputs
|
// Other Outputs
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user