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() {
|
||||
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) {
|
||||
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;
|
||||
this.trigger('modeChange', {mode});
|
||||
|
Loading…
Reference in New Issue
Block a user