Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions misc/keyvaluestorage/src/browser/lib/localStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@
return Object.keys(this).length;
});

if (typeof global !== "undefined" && global.localStorage) {
module.exports = global.localStorage;
} else if (typeof window !== "undefined" && window.localStorage) {
module.exports = window.localStorage;
} else {
try {
if (typeof global !== "undefined" && global.localStorage) {
module.exports = global.localStorage;
} else if (typeof window !== "undefined" && window.localStorage) {
module.exports = window.localStorage;
} else {
module.exports = new LocalStorage();
}
} catch {
// In Incognito mode, accessing window.localStorage may thorw an error
module.exports = new LocalStorage();
}
})();