Permalink
Browse files

Fix localstorage bug

  • Loading branch information...
1 parent 35c2fc7 commit 3340af44e4fafcf4510b9212ea92aceeb1d306a5 @mixu committed Jun 15, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 backends/browser_localstorage.js
@@ -3,8 +3,8 @@ var cache = false;
module.exports = {
write: function(str) {
if(typeof window == 'undefined' || !window.localStorage ||
- typeof JSON == 'undefined' || !JSON.stringify) return;
- if(!cache) { cache = window.localStorage.minilog || []; }
+ typeof JSON == 'undefined' || !JSON.stringify || !JSON.parse) return;
+ if(!cache) { cache = (window.localStorage.minilog ? JSON.parse(window.localStorage.minilog) : []); }
cache.push(new Date().toString() + ' '+ str);
window.localStorage.minilog = JSON.stringify(cache);
},

0 comments on commit 3340af4

Please sign in to comment.