Fix: rely on data-value-type instead of input name
This commit is contained in:
parent
7ae2f9ca3a
commit
88da38ef3a
|
@ -450,23 +450,22 @@ function setupLivePrefs(
|
||||||
if (input.type === 'radio' && !input.checked) {
|
if (input.type === 'radio' && !input.checked) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
// FIXME: use a string value for iconset
|
if (input.dataset.valueType === 'number') {
|
||||||
if (input.name === 'iconset') {
|
|
||||||
return Number(input.value);
|
return Number(input.value);
|
||||||
}
|
}
|
||||||
return input.value;
|
return input.value;
|
||||||
}
|
}
|
||||||
function setInputValue(input, value, force = false) {
|
function setInputValue(input, value, force = false) {
|
||||||
let oldValue, newValue;
|
let oldValue, newValue;
|
||||||
|
const inputValue = input.dataset.valueType === 'number' ? Number(input.value) : input.value;
|
||||||
if (input.type === 'radio') {
|
if (input.type === 'radio') {
|
||||||
oldValue = input.checked;
|
oldValue = input.checked;
|
||||||
// FIXME: use == because we use number value in iconset
|
newValue = input.checked = value === inputValue;
|
||||||
newValue = input.checked = value == input.value;
|
|
||||||
} else if (input.type === 'checkbox') {
|
} else if (input.type === 'checkbox') {
|
||||||
oldValue = input.checked;
|
oldValue = input.checked;
|
||||||
newValue = input.checked = value;
|
newValue = input.checked = value;
|
||||||
} else {
|
} else {
|
||||||
oldValue = input.value;
|
oldValue = inputValue;
|
||||||
newValue = input.value = value;
|
newValue = input.value = value;
|
||||||
}
|
}
|
||||||
if (force || oldValue !== newValue) {
|
if (force || oldValue !== newValue) {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<label>
|
<label>
|
||||||
<span i18n-text="optionsIconDark"></span>
|
<span i18n-text="optionsIconDark"></span>
|
||||||
<div class="iconset">
|
<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/16.png">
|
||||||
<img src="/images/icon/16w.png">
|
<img src="/images/icon/16w.png">
|
||||||
<img src="/images/icon/16x.png">
|
<img src="/images/icon/16x.png">
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<label>
|
<label>
|
||||||
<span i18n-text="optionsIconLight"></span>
|
<span i18n-text="optionsIconLight"></span>
|
||||||
<div class="iconset">
|
<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/16.png">
|
||||||
<img src="/images/icon/light/16w.png">
|
<img src="/images/icon/light/16w.png">
|
||||||
<img src="/images/icon/light/16x.png">
|
<img src="/images/icon/light/16x.png">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user