Permalink
Browse files

Bug fix for private browsing mode

Bug fix for browsers that have localStorage, but don't have any space (this can be replicated by turning on private browsing on Safari Mobile).
  • Loading branch information...
1 parent e886d67 commit d875f372f514c24cae57f35bc103e129931f5acd @stephen-uac committed Apr 9, 2013
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/jquery.offline.js
View
@@ -36,7 +36,16 @@
// Allow the user to explicitly turn off localStorage
// before loading this plugin
if (typeof $.support.localStorage === "undefined") {
- $.support.localStorage = !!window.localStorage;
+ var localStorageTest = function() {
+ try {
+ localStorage.setItem("test", "test");
+ localStorage.removeItem("test");
+ return true;
+ } catch(e) {
+ return false;
+ }
+ };
+ $.support.localStorage = !!window.localStorage && localStorageTest();
}
// modified getJSON which uses ifModified: true
@@ -162,6 +171,7 @@
"NS_ERROR_DOM_QUOTA_REACHED") {
cleanupLocalStorage();
}
+ break;
}
}

0 comments on commit d875f37

Please sign in to comment.