Fix: rely on data-value-type instead of input name

This commit is contained in:
eight 2019-06-26 18:01:03 +08:00
parent 7ae2f9ca3a
commit 88da38ef3a
2 changed files with 6 additions and 7 deletions

View File

@ -450,23 +450,22 @@ function setupLivePrefs(
if (input.type === 'radio' && !input.checked) {
return undefined;
}
// FIXME: use a string value for iconset
if (input.name === 'iconset') {
if (input.dataset.valueType === 'number') {
return Number(input.value);
}
return input.value;
}
function setInputValue(input, value, force = false) {
let oldValue, newValue;
const inputValue = input.dataset.valueType === 'number' ? Number(input.value) : input.value;
if (input.type === 'radio') {
oldValue = input.checked;
// FIXME: use == because we use number value in iconset
newValue = input.checked = value == input.value;
newValue = input.checked = value === inputValue;
} else if (input.type === 'checkbox') {
oldValue = input.checked;
newValue = input.checked = value;
} else {
oldValue = input.value;
oldValue = inputValue;
newValue = input.value = value;
}
if (force || oldValue !== newValue) {

View File

@ -41,7 +41,7 @@
<label>
<span i18n-text="optionsIconDark"></span>
<div class="iconset">
<input type="radio" name="iconset" value="0">
<input type="radio" name="iconset" value="0" data-value-type="number">
<img src="/images/icon/16.png">
<img src="/images/icon/16w.png">
<img src="/images/icon/16x.png">
@ -50,7 +50,7 @@
<label>
<span i18n-text="optionsIconLight"></span>
<div class="iconset">
<input type="radio" name="iconset" value="1">
<input type="radio" name="iconset" value="1" data-value-type="number">
<img src="/images/icon/light/16.png">
<img src="/images/icon/light/16w.png">
<img src="/images/icon/light/16x.png">