yckart / jquery.storage.js

The client-side storage for every browser, on any device.
http://yckart.github.com/jquery.storage.js/
49 stars 12 forks source link

HTML5 localstorage ‘illegal access’ bugfix #2

Open dutscher opened 11 years ago

dutscher commented 11 years ago

hey, i've found a bug in your localStorage plugin. My Android Phone has 2.3.3 and even i tried to get the value of the storage it crashed while JSON can't handle null parameters. This is what i found about: http://zsitro.com/html5-localstorage-illegal-access-bugfix/

And with this i have refactor to your code:

var returns = function(key){ return JSON.parse($.support[method] ? window[method].getItem(key) : $.cookie(options.cookiePrefix + key)); };

to that:

var returns = function(key){ var objReturn = null; if($.support[method]){ objReturn = window[method].getItem(key) ? JSON.parse(window[method].getItem(key)) : null; } else { objReturn = JSON.parse($.cookie(options.cookiePrefix + key)); } return objReturn; };

cheers