mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 03:42:41 +08:00
DEV: Gracefully handle missing localstorage in dev-tools initializer (#30643)
I'm not sure if this is a real-world consideration... but our `test/smoke-test.mjs` script runs chrome with `--disable-local-storage`, so it needs to work.
This commit is contained in:
parent
498481e5be
commit
2ff511a4e4
|
@ -4,7 +4,7 @@ import { isDevelopment } from "discourse-common/config/environment";
|
|||
const KEY = "discourse__dev_tools";
|
||||
|
||||
function parseStoredValue() {
|
||||
const val = window.localStorage.getItem(KEY);
|
||||
const val = window.localStorage?.getItem(KEY);
|
||||
if (val === "true") {
|
||||
return true;
|
||||
} else if (val === "false") {
|
||||
|
@ -26,9 +26,9 @@ export default {
|
|||
|
||||
function storeValue(value) {
|
||||
if (value === defaultEnabled) {
|
||||
window.localStorage.removeItem(KEY);
|
||||
window.localStorage?.removeItem(KEY);
|
||||
} else {
|
||||
window.localStorage.setItem(KEY, value);
|
||||
window.localStorage?.setItem(KEY, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user