From 31558d5071effa136b3ef1f912bcd9c578d1a688 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 4 Nov 2020 12:50:24 +0300 Subject: [PATCH] we use 'true' and 'false' strings as boolean T_T fixup for b56dacb --- js/prefs.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/prefs.js b/js/prefs.js index 236447c4..4434df6a 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -140,18 +140,19 @@ window.INJECTED !== 1 && (() => { get(key) { return isKnown(key) && values[key]; }, - set(key, value, isSynced) { + set(key, val, isSynced) { if (!isKnown(key)) return; const oldValue = values[key]; const type = typeof defaults[key]; - if (type !== typeof value) { - if (type === 'string') value = String(value); - if (type === 'number') value = Number(value) || 0; - if (type === 'boolean') value = Boolean(value); + if (type !== typeof val) { + 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 (value !== oldValue && !simpleDeepEqual(value, oldValue)) { - values[key] = value; - emitChange(key, value, isSynced); + if (val !== oldValue && !simpleDeepEqual(val, oldValue)) { + values[key] = val; + emitChange(key, val, isSynced); } }, reset(key) {