mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-16 12:25:53 +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) {
|
||||
var val = localStorage.getItem(makeKey(key))
|
||||
return typeof val === 'string' ? JSON.parse(val) : val
|
||||
var val = localStorage[makeKey(key)]
|
||||
try {
|
||||
while (typeof val === 'string') val = JSON.parse(val)
|
||||
} catch (e) {
|
||||
//console.log('string?')
|
||||
}
|
||||
return 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) {
|
||||
localStorage.removeItem(makeKey(key))
|
||||
delete localStorage[makeKey(key)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue