Work even if localStorage throws a SECURITY_ERR (fixes #772)

This commit is contained in:
John Firebaugh
2013-02-16 10:14:05 -08:00
parent 1fec2513e4
commit 766a0f5ce3

View File

@@ -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];