-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fixes an issue where default storage was read-only #172
Conversation
lib/storageUtil.js
Outdated
@@ -22,7 +22,8 @@ var storageUtil = {}; | |||
// https://connect.microsoft.com/IE/Feedback/Details/1496040 | |||
storageUtil.browserHasLocalStorage = function() { | |||
try { | |||
if (storageUtil.getLocalStorage()) { | |||
var storage = storageUtil.getLocalStorage(); | |||
if (storageUtil.testStorage(storage)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: return storageUtil.testStorage(storage)
@@ -73,4 +75,15 @@ storageUtil.getCookieStorage = function() { | |||
}; | |||
}; | |||
|
|||
storageUtil.testStorage = function(storage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if it's worth to check null-able of storage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that as well. Attempting to call setItem
on undefined
or null
will throw a TypeError
, which will result in returning false
. I think we should be safe thanks to wrapping this in a try catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
This reverts commit c384006.
Description
Fixes an issue where checking if
localStorage
and/orsessionStorage
was returningtrue
, even though it cannot be written to.See:
Example
Here is an example using iOS 10 Safari: