tymondesigns / angular-locker

🗄️ A simple & configurable abstraction for local/session storage in angular js projects
https://npm.im/angular-locker
MIT License
314 stars 42 forks source link

Safari Private Browsing #31

Closed SeanProulx closed 8 years ago

SeanProulx commented 8 years ago

We need to be able to support Safari private browsing in our project but if the storage isn't supported, the browser just throws a JS exception and our angular app doesn't initialize. I've noticed the use of Remy's Polyfill but is this just a plug and play script? How exactly am I supposed to use this in a project?

Currently we fallback to $cookies using locker.isSupported() but I don't understand the point of this function if I can't call or check it?

SeanProulx commented 8 years ago

Solved this issue by implementing something similar to what @tmcgee123 posted, except we're using the $cookies service instead.

Thanks again for the lib and hard work! A+

tmcgee123 commented 8 years ago

Sweet! Glad someone else was able to use it!!

tymondesigns commented 8 years ago

Cheers guys :+1:

aaronmallen commented 7 years ago

Where can I find what @tmcgee123 posted? We are having the same issue. I'm assuming this polyfill is what is being referenced? If so can we get this incorporated into angular locker in some way?

tymondesigns commented 7 years ago

here is the gist https://gist.github.com/tmcgee123/c25325d70277b2ee3f3a

it's not really something that should go in the lib itself though

aaronmallen commented 7 years ago

@tymondesigns understood :+1:

seven-cd commented 7 years ago

Not sure if this works. https://gist.github.com/tmcgee123/c25325d70277b2ee3f3a

LockerFallback is never called in Private Browsing.

tmcgee123 commented 7 years ago

@seven-cd That is sheerly a decorator for the service, so anyone could take it and simply include the module in their application and it will override the locker provider. If you are not familiar with decorators, here's the link: https://docs.angularjs.org/api/auto/service/$provide#decorator

All you have to do is include the code in your application then inject the module to where you are bootstrapping angular-locker currently.

andreaslarssen commented 7 years ago

Is the decoration approach still how this is done? I thought I read somewhere that this issue had been fixed and merged, but can't to find back to it. Also, it seems to not work with 2.0.4. Looking further into it now,

andreaslarssen commented 6 years ago

And, @tymondesigns, if I understand you correctly, fallback to cookie driver (or whatever) where other drivers are not supported (like Safari private mode) is not considered the scope of Locker, and should be handled in all applications needed to support missing localStorage support? IE. a feature, not a bug?