From 83aaaac519ec7d8fb371d941efc281182fedcce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sk=C3=B6ld?= Date: Thu, 31 Jan 2013 17:48:20 +0100 Subject: [PATCH] Mobile Safari (private mode) is broken with debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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... --- debug.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debug.js b/debug.js index b5fe1bc..e47ba5b 100644 --- a/debug.js +++ b/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); \ No newline at end of file +if (window.localStorage) debug.enable(localStorage.debug);