Skip to content

Commit

Permalink
fix: security error on safari - closes #167
Browse files Browse the repository at this point in the history
  • Loading branch information
yields committed Jan 7, 2015
1 parent 24cc5c0 commit 988592b
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 988592b

Please sign in to comment.