From 307e5b893dd4ec0b7336c5662f733396e69b01dd Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 16 Aug 2013 13:22:04 -0700 Subject: [PATCH] Use localStorage.{get,set,remove}Item Using property accessors seems to be buggy on FF. --- js/id/id.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/id/id.js b/js/id/id.js index c6a265b45..a5b7451ea 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -8,12 +8,16 @@ window.iD = function () { // https://github.com/systemed/iD/issues/772 // http://mathiasbynens.be/notes/localstorage-pattern#comment-9 try { storage = localStorage; } catch (e) {} - storage = storage || {}; + storage = storage || { + getItem: function() {}, + setItem: function() {}, + removeItem: function() {} + }; context.storage = function(k, v) { - if (arguments.length === 1) return storage[k]; - else if (v === null) delete storage[k]; - else storage[k] = v; + if (arguments.length === 1) return storage.getItem(k); + else if (v === null) storage.removeItem(k); + else storage.setItem(k, v); }; var history = iD.History(context),