aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-08-24 18:26:04 -0400
committerGitHub <noreply@github.com>2020-08-24 18:26:04 -0400
commitbbfe5f81cbd938d4ca2f23088b1ff332cd82e7aa (patch)
tree2c7204093b676e34490275884c7bcd4a21f78796 /ext/mixed
parent6e31f24ed16147c56c491314cfc9183ccf1b09b6 (diff)
Fix sessionStorage not being supported when cookies are disabled (#756)
* Fix sessionStorage not being supported when cookies are disabled * Update comment
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 6e41a190..4a8605e5 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -1319,17 +1319,26 @@ class Display extends EventDispatcher {
}
_updateMode() {
- const mode = sessionStorage.getItem('mode');
+ let mode = null;
+ try {
+ mode = sessionStorage.getItem('mode');
+ } catch (e) {
+ // Browsers can throw a SecurityError when cookie blocking is enabled.
+ }
this._setMode(mode, false);
}
_setMode(mode, save) {
if (mode === this._mode) { return; }
if (save) {
- if (mode === null) {
- sessionStorage.removeItem('mode');
- } else {
- sessionStorage.setItem('mode', mode);
+ try {
+ if (mode === null) {
+ sessionStorage.removeItem('mode');
+ } else {
+ sessionStorage.setItem('mode', mode);
+ }
+ } catch (e) {
+ // Browsers can throw a SecurityError when cookie blocking is enabled.
}
}
this._mode = mode;