-
Notifications
You must be signed in to change notification settings - Fork 945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup browser tests and fix null reference check on window.documentElement.style.WebkitAppearance #447
Merged
Merged
cleanup browser tests and fix null reference check on window.documentElement.style.WebkitAppearance #447
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,20 +40,20 @@ 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' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { | ||
if (window && window.process && 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' && document && 'WebkitAppearance' in document.documentElement.style) || | ||
return (document && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only really important line it seems like. For the purposes of fixing #436, maybe we can narrow the bug fix commit to just a one-liner commit. And perhaps address other styling fixes for this code separately. |
||
// is firebug? http://stackoverflow.com/a/398120/376773 | ||
(typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || | ||
(window && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || | ||
// is firefox >= v31? | ||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages | ||
(typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || | ||
(navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || | ||
// double check webkit in userAgent just in case we are in a worker | ||
(typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); | ||
(navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); | ||
} | ||
|
||
/** | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
typeof window !== 'undefined'
stuff is important, because that will return false if window is not defined, but simplywindow
will throw an error if it is not defined. All of the root-level variables should stick with the typeof check IMO. Once that first check passes then checking for thuthyness should be enough for the properties after that.