Skip to content

Added fix for Private mode in Safari - #33

Merged
pimterry merged 2 commits into
pimterry:masterfrom
smallhadroncollider:master
Dec 8, 2013
Merged

Added fix for Private mode in Safari#33
pimterry merged 2 commits into
pimterry:masterfrom
smallhadroncollider:master

Conversation

@smallhadroncollider

Copy link
Copy Markdown
Contributor

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 localStorageAvailable check. It's not terribly elegant and seems strange before running the checks for the localStorage object, but it does work.

@pimterry

pimterry commented Dec 6, 2013

Copy link
Copy Markdown
Owner

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.

@smallhadroncollider

Copy link
Copy Markdown
Contributor Author

I wanted to avoid additional try/catch blocks as I know they affect performance, but I agree that reusing the existing call to localStorage is a more elegant solution. It would be the most minute of performance hits in any case.

@pimterry

pimterry commented Dec 6, 2013

Copy link
Copy Markdown
Owner

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!

@smallhadroncollider

Copy link
Copy Markdown
Contributor Author

I've made the changes and pushed it. Do I need to open a new pull request?

pimterry added a commit that referenced this pull request Dec 8, 2013
Added fix for Private mode in Safari
@pimterry
pimterry merged commit 4ed8bd9 into pimterry:master Dec 8, 2013
@pimterry

pimterry commented Dec 8, 2013

Copy link
Copy Markdown
Owner

Nope, it automatically updates the PR as soon as you push to your branch. Merged, thanks!

@jfroom

jfroom commented Mar 17, 2014

Copy link
Copy Markdown

I'm running into this issue with a regular iOS 7.1 safari web app I'm trying to build. This is the error:
http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-safari-quota-exceeded-err-dom-exception-22-an

I get the error on my app's initialization and then the entire app fails to initialize.

@pimterry

Copy link
Copy Markdown
Owner

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.

@jfroom

jfroom commented Mar 18, 2014

Copy link
Copy Markdown

Thanks Tim. I swapped loglevel out for JSNLog to hit a deadline. Next time
around I'll give loglevel a try again. Cheers.

On Tue, Mar 18, 2014 at 4:28 AM, Tim Perry notifications@github.com wrote:

Ah, sorry @jfroom https://github.com/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.

Reply to this email directly or view it on GitHubhttps://github.com//pull/33#issuecomment-37913038
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants