Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mobile Safari (private mode) is broken with debug

Mobile Safari has a dumb feature where it goes ahead and throws an exception when trying to access the localStorage in private mode.  

Other people with the same issue: 
http://meta.stackoverflow.com/questions/123116/safari-5-1-2-log-in-doesnt-work  

Simply wrapping the local storage access in a try/catch should do the trick...
  • Loading branch information...
commit 83aaaac519ec7d8fb371d941efc281182fedcce7 1 parent 73936c4
@slaskis slaskis authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 debug.js
View
6 debug.js
@@ -50,7 +50,9 @@ debug.skips = [];
*/
debug.enable = function(name) {
- localStorage.debug = name;
+ try {
+ localStorage.debug = name;
+ } catch(e){}
var split = (name || '').split(/[\s,]+/)
, len = split.length;
@@ -119,4 +121,4 @@ debug.enabled = function(name) {
// persist
-if (window.localStorage) debug.enable(localStorage.debug);
+if (window.localStorage) debug.enable(localStorage.debug);
Please sign in to comment.
Something went wrong with that request. Please try again.