Skip to content

Commit

Permalink
Work around debug being loaded in preload scripts (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts authored and thebigredgeek committed Dec 14, 2016
1 parent e1ee4d5 commit 69480c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ exports.colors = [
*/

function useColors() {
// NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we're in Chrome, we'll just detect this case
// explicitly
if (typeof window !== 'undefined' && 'process' in window && window.process.type === 'renderer') {
return true;
}

// is webkit? http://stackoverflow.com/a/16459606/376773
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) ||
Expand Down

0 comments on commit 69480c3

Please sign in to comment.