only use localStorage if available

This commit is contained in:
Laura Klünder 2018-12-17 00:24:39 +01:00
parent a87f5632bc
commit df6eed44cf

View file

@ -1472,7 +1472,7 @@ SquareGridControl = L.Control.extend({
this._button.href = '#';
this._button.style.color = '#BBBBBB';
this.gridActive = false;
if (localStorage.getItem('showGrid')) {
if (localStorage && localStorage.getItem('showGrid')) {
this.showGrid()
}
return this._container;
@ -1493,7 +1493,7 @@ SquareGridControl = L.Control.extend({
this._button.innerHTML = 'grid_on';
this._button.style.color = '';
this.gridActive = true;
localStorage.setItem('showGrid', true);
if (localStorage) localStorage.setItem('showGrid', true);
},
hideGrid: function() {
@ -1502,7 +1502,7 @@ SquareGridControl = L.Control.extend({
this._button.innerHTML = 'grid_off';
this._button.style.color = '#BBBBBB';
this.gridActive = false;
localStorage.removeItem('showGrid');
if (localStorage) localStorage.removeItem('showGrid');
}
});