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...
This commit is contained in:
Robert Sköld 2013-01-31 17:48:20 +01:00
parent 73936c4ddf
commit 83aaaac519

View File

@ -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);