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:
parent
6eb4fbeead
commit
8fabcabebb
@ -115,15 +115,17 @@ 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
|
||||||
|
if(window.localStorage) {
|
||||||
for(var index=window.localStorage.length - 1; index>=0; index--) {
|
for(var index=window.localStorage.length - 1; index>=0; index--) {
|
||||||
var key = window.localStorage.key(index),
|
var key = window.localStorage.key(index),
|
||||||
parts = key.split("#");
|
parts = key.split("#");
|
||||||
// Delete it if it's ours
|
// Delete it if it is ours
|
||||||
if(parts[0] === "tw5" && parts[1] === url) {
|
if(parts[0] === "tw5" && parts[1] === url) {
|
||||||
window.localStorage.removeItem(key);
|
window.localStorage.removeItem(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user