Closed schlingel closed 11 years ago
Hm, I don't see how that could happen, but there's a different problem. If you use totalStorage both to set and retrieve a value everything should work fine because it performs JSON.stringify on value set and JSON.parse on value get.
However, if you set the value natively using window.localStorage.setItem('key', 'value'), you will not be able to retrieve it using totalStorage, as it would fail in parseResult as you've noted.
Basically, totalStorage is trying to accomodate all input values and sacrifices transparency while doing so.
Thanks for the heads-up on this. I've fixed the code to work with window.localStorage.setItem so that values can go back-and-forth.
I got strange results when I tried to add String values to the localStorage. E.g.
jQuery.totalStorage('Klaus', 'asdf'); console.log(jQuery.totalStorage('Klaus'));
printed undefined.
That's because in my Chrome browser JSON.parse throws an SyntaxError exception, so I had to add return res in the catch branch.
Now it works.