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,18 +1319,27 @@ 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) {
|
||||||
|
try {
|
||||||
if (mode === null) {
|
if (mode === null) {
|
||||||
sessionStorage.removeItem('mode');
|
sessionStorage.removeItem('mode');
|
||||||
} else {
|
} else {
|
||||||
sessionStorage.setItem('mode', mode);
|
sessionStorage.setItem('mode', mode);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Browsers can throw a SecurityError when cookie blocking is enabled.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this._mode = mode;
|
this._mode = mode;
|
||||||
this.trigger('modeChange', {mode});
|
this.trigger('modeChange', {mode});
|
||||||
|
Loading…
Reference in New Issue
Block a user