1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Browserstorage plugin: don't crash if local storage not available

Fix #6701
This commit is contained in:
jeremy@jermolene.com 2022-05-21 15:36:23 +01:00
parent 6eb4fbeead
commit 8fabcabebb

View File

@ -115,13 +115,15 @@ function saveTiddlerToLocalStorage(title,options) {
function clearLocalStorage() { function clearLocalStorage() {
var url = window.location.pathname, var url = window.location.pathname,
log = []; log = [];
// Step through each browsder storage item // Step through each browser storage item
for(var index=window.localStorage.length - 1; index>=0; index--) { if(window.localStorage) {
var key = window.localStorage.key(index), for(var index=window.localStorage.length - 1; index>=0; index--) {
parts = key.split("#"); var key = window.localStorage.key(index),
// Delete it if it's ours parts = key.split("#");
if(parts[0] === "tw5" && parts[1] === url) { // Delete it if it is ours
window.localStorage.removeItem(key); if(parts[0] === "tw5" && parts[1] === url) {
window.localStorage.removeItem(key);
}
} }
} }
} }