parent
97ad0753e0
commit
31558d5071
17
js/prefs.js
17
js/prefs.js
|
@ -140,18 +140,19 @@ window.INJECTED !== 1 && (() => {
|
||||||
get(key) {
|
get(key) {
|
||||||
return isKnown(key) && values[key];
|
return isKnown(key) && values[key];
|
||||||
},
|
},
|
||||||
set(key, value, isSynced) {
|
set(key, val, isSynced) {
|
||||||
if (!isKnown(key)) return;
|
if (!isKnown(key)) return;
|
||||||
const oldValue = values[key];
|
const oldValue = values[key];
|
||||||
const type = typeof defaults[key];
|
const type = typeof defaults[key];
|
||||||
if (type !== typeof value) {
|
if (type !== typeof val) {
|
||||||
if (type === 'string') value = String(value);
|
if (type === 'string') val = String(val);
|
||||||
if (type === 'number') value = Number(value) || 0;
|
if (type === 'number') val = Number(val) || 0;
|
||||||
if (type === 'boolean') value = Boolean(value);
|
if (type === 'boolean') val = val === 'true' || val !== 'false' && Boolean(val);
|
||||||
|
// 'true' and 'false' strings are used by manage.html in `.invert` elements
|
||||||
}
|
}
|
||||||
if (value !== oldValue && !simpleDeepEqual(value, oldValue)) {
|
if (val !== oldValue && !simpleDeepEqual(val, oldValue)) {
|
||||||
values[key] = value;
|
values[key] = val;
|
||||||
emitChange(key, value, isSynced);
|
emitChange(key, val, isSynced);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset(key) {
|
reset(key) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user