From 641ef7ccf9fec546c48d8255e8791e0f68b8d3ee Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Fri, 13 Sep 2013 16:15:27 -0700 Subject: [PATCH] safeGet/safeSet: Don't bother if store.js is disabled. For IE with localStorage disabled, store.js can raise exceptions if you attempt to use it when it is "disabled" (cannot select a backend). --- r2/r2/public/static/js/base.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/r2/r2/public/static/js/base.js b/r2/r2/public/static/js/base.js index 0e7688898..72e7adbe0 100644 --- a/r2/r2/public/static/js/base.js +++ b/r2/r2/public/static/js/base.js @@ -37,6 +37,10 @@ r.ajax = function(request) { } store.safeGet = function(key, errorValue) { + if (store.disabled) { + return errorValue + } + // errorValue defaults to undefined, equivalent to the key being unset. try { return store.get(key) @@ -51,6 +55,10 @@ store.safeGet = function(key, errorValue) { } store.safeSet = function(key, val) { + if (store.disabled) { + return false + } + // swallow exceptions upon storage set for non-trivial operations. returns // a boolean value indicating success. try {