Skip to content

Commit

Permalink
Merge pull request #104 from thomasconner/master
Browse files Browse the repository at this point in the history
Check if window is available before using it
  • Loading branch information
pimterry authored May 11, 2017
2 parents 41282bf + b9d9e00 commit d3705dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"curly": true,
"curly": false,
"eqeqeq": true,
"immed": true,
"latedef": true,
Expand Down
2 changes: 1 addition & 1 deletion lib/.jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"curly": true,
"curly": false,
"eqeqeq": true,
"immed": true,
"latedef": true,
Expand Down
4 changes: 4 additions & 0 deletions lib/loglevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
function persistLevelIfPossible(levelNum) {
var levelName = (logMethods[levelNum] || 'silent').toUpperCase();

if (typeof window === undefinedType) return;

// Use localStorage if available
try {
window.localStorage[storageKey] = levelName;
Expand All @@ -117,6 +119,8 @@
function getPersistedLevel() {
var storedLevel;

if (typeof window === undefinedType) return;

try {
storedLevel = window.localStorage[storageKey];
} catch (ignore) {}
Expand Down

0 comments on commit d3705dc

Please sign in to comment.