-
Notifications
You must be signed in to change notification settings - Fork 941
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
MS Edge broken colors #417
Comments
I just recently started getting a similar issue on Chrome as well. However, it doesn't have the color arguments at the end:
macOS 10.12.2 |
Appears to be an intermittent issue on Chrome... Rebuilt my project, opened it in a new tab, and now it's working again. 🤷♂️ |
I'm seeing this on Edge as well. IE shows non-colored output and every other browser shows proper color output:
|
Does Edge just simply not support colored logs? Should be easy enough to adjust the |
I am having the same issue in Edge. |
Assuming that Edge does not support colored logs (is that?), shouldn't the |
@TooTallNate would you accept a PR making 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.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.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
// is firebug? http://stackoverflow.com/a/398120/376773
(typeof window !== 'undefined' && 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.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.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
} Note the latest condition: navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/) It happens that the
so Edge is falsely detected as "webkit" and, hence, colors are enabled. We just need to disable Edge (and IE) which can be done by adding the following checks at the beginning: function useColors() {
// Internet Explorer and Edge do not support colors.
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))
return false;
// [...] |
This is the literal output in the console for MS Edge (without any color applied to it's output):
%cmyModule:myService %ccheckEmail%c +0ms color: lightseagreen color: inherit color: lightseagreen false
The text was updated successfully, but these errors were encountered: