Added fix for Private mode in Safari - #33
Conversation
|
Oooh really? Good find, thanks, and sensible fix. I would like to make this a little tidier though, as you say. Is it possible to do this neatly if you move the try/catch around the actual localStorage['loglevel'] write instead, and then potentially falling back to cookies then? Means we only have to write to localStorage once too, which is nice. |
|
I wanted to avoid additional try/catch blocks as I know they affect performance, but I agree that reusing the existing call to |
|
Yup, agreed. I did worry about performance too a little, but actually it's only on the setLevel call, which I think it's pretty unlikely that people are going to be doing in a tight loop! All sounds good though, push that change in too and I'll merge this. Thanks! |
… need for extra test calls
|
I've made the changes and pushed it. Do I need to open a new pull request? |
Added fix for Private mode in Safari
|
Nope, it automatically updates the PR as soon as you push to your branch. Merged, thanks! |
|
I'm running into this issue with a regular iOS 7.1 safari web app I'm trying to build. This is the error: I get the error on my app's initialization and then the entire app fails to initialize. |
|
Ah, sorry @jfroom, this hadn't yet made it to being fully released, since I'd had other things that also needed merging in at the time. That's all done now though, so I've just created and published a release; if you update to 0.6.0 this should be fixed. |
|
Thanks Tim. I swapped loglevel out for JSNLog to hit a deadline. Next time On Tue, Mar 18, 2014 at 4:28 AM, Tim Perry notifications@github.com wrote:
|
Running loglevel in Safari with Private mode (which I often do for testing) creates a DOM 22 Exception. I assume this is because you can't use local storage in Private Mode.
The added code will cause the exception in the
localStorageAvailablecheck. It's not terribly elegant and seems strange before running the checks for thelocalStorageobject, but it does work.