Last active
March 21, 2016 08:48
-
-
Save danb-humaan/4b43cdb5e7be1426edfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determines whether the browser supports localStorage or not. | |
* | |
* This method is required due to iOS Safari in Private Browsing mode incorrectly says it supports localStorage, when it in fact does not. | |
* | |
* @kind function | |
* @function LocalStorage#supportsLocalStorage | |
* | |
* @returns {boolean} Returns true if setting and removing a localStorage item is successful, or false if it's not. | |
*/ | |
supportsLocalStorage: function () { | |
try { | |
localStorage.setItem('_', '_'); | |
localStorage.removeItem('_'); | |
return true; | |
} catch (e) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment