Skip to content

Commit

Permalink
Merge pull request #42 from mixophrygian/master
Browse files Browse the repository at this point in the history
wrap first call to window.localStorage in a try/catch, fixes #41
  • Loading branch information
notwaldorf authored Jul 13, 2016
2 parents 5880245 + 50c85ff commit 8d18119
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions iron-localstorage.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@
* @param {boolean=} externalChange true if loading changes from a different window
*/
_load: function(externalChange) {
var v = window.localStorage.getItem(this.name);
try {
var v = window.localStorage.getItem(this.name);
} catch (ex) {
this.errorMessage = ex.message;

this._error("Could not save to localStorage. Try enabling cookies for this page.", ex);
};

if (v === null) {
this._loaded = true;
Expand Down Expand Up @@ -221,7 +227,7 @@
catch(ex) {
// Happens in Safari incognito mode,
this.errorMessage = ex.message;
Polymer.Base._error("localStorage could not be saved. Safari incognito mode?", ex);
Polymer.Base._error("Could not save to localStorage. Incognito mode may be blocking this action", ex);
}
}

Expand Down

0 comments on commit 8d18119

Please sign in to comment.