Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7ab38e4

Browse files
committedApr 26, 2017
cleanup browser tests and fix null reference check on window.documentElement.style.WebkitAppearance
1 parent f311b10 commit 7ab38e4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎src/browser.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ function useColors() {
4040
// NB: In an Electron preload script, document will be defined but not fully
4141
// initialized. Since we know we're in Chrome, we'll just detect this case
4242
// explicitly
43-
if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') {
43+
if (window && window.process && window.process.type === 'renderer') {
4444
return true;
4545
}
4646

4747
// is webkit? http://stackoverflow.com/a/16459606/376773
4848
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
49-
return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) ||
49+
return (document && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
5050
// is firebug? http://stackoverflow.com/a/398120/376773
51-
(typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) ||
51+
(window && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
5252
// is firefox >= v31?
5353
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
54-
(typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
54+
(navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
5555
// double check webkit in userAgent just in case we are in a worker
56-
(typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
56+
(navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
5757
}
5858

5959
/**

0 commit comments

Comments
 (0)
Please sign in to comment.