Skip to content

Commit 69480c3

Browse files
anaisbettsthebigredgeek
authored andcommitted
Work around debug being loaded in preload scripts (#368)
1 parent e1ee4d5 commit 69480c3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

browser.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ exports.colors = [
3737
*/
3838

3939
function useColors() {
40+
// NB: In an Electron preload script, document will be defined but not fully
41+
// initialized. Since we know we're in Chrome, we'll just detect this case
42+
// explicitly
43+
if (typeof window !== 'undefined' && 'process' in window && window.process.type === 'renderer') {
44+
return true;
45+
}
46+
4047
// is webkit? http://stackoverflow.com/a/16459606/376773
4148
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
4249
return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) ||

0 commit comments

Comments
 (0)