maccman/spine — Issue #117: localstorage plugin broken in Chrome
Author: orthecreedence
Created: 2011-10-12 17:37:03+00:00
State: open

When using the local storage plugin for the Todo example, I got a recurring error where everytime I saved something to local storage, the next time I loaded the page, it tried to decode "undefined" as JSON.

I opened the local storage plugin and found the lines:

saveLocal: function() {
var result;
result = JSON.stringify(this);
return localStorage[this.className] = result;
},

I changed this to

saveLocal: function() {
var result;
result = JSON.stringify(this.toJSON()); // <-- note the .toJSON()
return localStorage[this.className] = result;
},

And it now works in Chrome, and all other browsers. Is this correct?