Skip to content

Commit 17f64df

Browse files
authored
fix(debug): add bug work around (#845)
* fix(debug): add bug work around * fix(debug): lint issues
1 parent c7474f2 commit 17f64df

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/lib/debug.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@ let _debug
22
const noop = () => undefined
33

44
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
5+
// Heads Up!
6+
// https://github.com/visionmedia/debug/pull/331
7+
//
8+
// debug now clears storage on load, grab the debug settings before require('debug').
9+
// We try/catch here as Safari throws on localStorage access in private mode or with cookies disabled.
10+
let DEBUG
11+
try {
12+
DEBUG = window.localStorage.debug
13+
} catch (e) {
14+
/* eslint-disable no-console */
15+
console.warning('Semantic-UI-React could not enable debug.')
16+
console.error(e)
17+
/* eslint-enable no-console */
18+
}
19+
520
_debug = require('debug')
21+
22+
// enable what ever settings we got from storage
23+
_debug.enable(DEBUG)
624
} else {
725
_debug = () => noop
826
}

0 commit comments

Comments
 (0)