mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 08:17:58 -05:00
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).
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user