Skip to content

Commit

Permalink
Merge pull request #168 from yields/fix/security-error
Browse files Browse the repository at this point in the history
fix: security error on safari - closes #167
  • Loading branch information
TooTallNate committed Jan 13, 2015
2 parents 24cc5c0 + 988592b commit 2c38441
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var storage;
if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')
storage = chrome.storage.local;
else
storage = window.localStorage;
storage = localstorage();

/**
* Colors.
Expand Down Expand Up @@ -156,3 +156,20 @@ function load() {
*/

exports.enable(load());

/**
* Localstorage attempts to return the localstorage.
*
* This is necessary because safari throws
* when a user disables cookies/localstorage
* and you attempt to access it.
*
* @return {LocalStorage}
* @api private
*/

function localstorage(){
try {
return window.localStorage;
} catch (e) {}
}

0 comments on commit 2c38441

Please sign in to comment.