Fix sessionStorage not being supported when cookies are disabled (#756)
* Fix sessionStorage not being supported when cookies are disabled * Update comment
This commit is contained in:
parent
6e31f24ed1
commit
bbfe5f81cb
@ -1319,17 +1319,26 @@ class Display extends EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateMode() {
|
_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);
|
this._setMode(mode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setMode(mode, save) {
|
_setMode(mode, save) {
|
||||||
if (mode === this._mode) { return; }
|
if (mode === this._mode) { return; }
|
||||||
if (save) {
|
if (save) {
|
||||||
if (mode === null) {
|
try {
|
||||||
sessionStorage.removeItem('mode');
|
if (mode === null) {
|
||||||
} else {
|
sessionStorage.removeItem('mode');
|
||||||
sessionStorage.setItem('mode', mode);
|
} else {
|
||||||
|
sessionStorage.setItem('mode', mode);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Browsers can throw a SecurityError when cookie blocking is enabled.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._mode = mode;
|
this._mode = mode;
|
||||||
|
Loading…
Reference in New Issue
Block a user