From 69480c3bd1b61413b3d5c543d75505ccde774614 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 14 Dec 2016 15:58:20 -0800 Subject: [PATCH] Work around debug being loaded in preload scripts (#368) --- browser.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/browser.js b/browser.js index f907c708..a2552839 100644 --- a/browser.js +++ b/browser.js @@ -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) ||