fix 'true' === true check in setupLivePrefs

This commit is contained in:
tophf 2021-01-07 14:49:22 +03:00
parent 1308efb8d0
commit 312f444ec7
2 changed files with 8 additions and 2 deletions

View File

@ -303,11 +303,18 @@ function setupLivePrefs(ids = prefs.knownKeys.filter(id => $('#' + id))) {
'value';
}
function isSame(el, propName, value) {
return el[propName] === value ||
typeof value === 'boolean' &&
el.tagName === 'SELECT' &&
el[propName] === `${value}`;
}
function updateElement(id, value) {
const el = $('#' + id);
if (el) {
const prop = getPropName(el);
if (el[prop] !== value || forceUpdate) {
if (!isSame(el, prop, value) || forceUpdate) {
el[prop] = value;
el.dispatchEvent(new Event('change', {bubbles: true}));
}

View File

@ -177,7 +177,6 @@
if (type === 'string') val = String(val);
if (type === 'number') val = Number(val) || 0;
if (type === 'boolean') val = val === 'true' || val !== 'false' && Boolean(val);
// 'true' and 'false' strings are used by manage.html in `.invert` elements
}
if (val !== oldValue && !simpleDeepEqual(val, oldValue)) {
values[key] = val;