mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
workaround weird local storage bug ... need to bisect to find the cause
This commit is contained in:
parent
3bfea85585
commit
dbecaed8c6
1 changed files with 9 additions and 4 deletions
|
|
@ -18,14 +18,19 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
get: function(key) {
|
get: function(key) {
|
||||||
var val = localStorage.getItem(makeKey(key))
|
var val = localStorage[makeKey(key)]
|
||||||
return typeof val === 'string' ? JSON.parse(val) : val
|
try {
|
||||||
|
while (typeof val === 'string') val = JSON.parse(val)
|
||||||
|
} catch (e) {
|
||||||
|
//console.log('string?')
|
||||||
|
}
|
||||||
|
return val
|
||||||
},
|
},
|
||||||
set: function(key, val) {
|
set: function(key, val) {
|
||||||
localStorage.setItem(makeKey(key), JSON.stringify(val))
|
localStorage[makeKey(key)] = typeof val === 'string' ? val : JSON.stringify(val)
|
||||||
},
|
},
|
||||||
remove: function(key) {
|
remove: function(key) {
|
||||||
localStorage.removeItem(makeKey(key))
|
delete localStorage[makeKey(key)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue