From 766a0f5ce3826ea87668b3b64cdbd4aa39dc246a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 16 Feb 2013 10:14:05 -0800 Subject: [PATCH] Work even if localStorage throws a SECURITY_ERR (fixes #772) --- js/id/id.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/id/id.js b/js/id/id.js index 29338b1a3..5dc8fb127 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -1,6 +1,11 @@ window.iD = function () { var context = {}, - storage = localStorage || {}; + storage; + + // https://github.com/systemed/iD/issues/772 + // http://mathiasbynens.be/notes/localstorage-pattern#comment-9 + try { storage = localStorage } catch (e) {} + storage = storage || {}; context.storage = function(k, v) { if (arguments.length === 1) return storage[k];