question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MS Edge broken colors

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
TooTallNatecommented, Mar 16, 2017

Does Edge just simply not support colored logs? Should be easy enough to adjust the supportsColors() function to support Edge.

0reactions
ibccommented, Aug 20, 2017

@TooTallNate would you accept a PR making supportsColors() return false when in Edge and Internet Explorer? Here the current problem:

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 User-Agent string of Edge looks as follows:

Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0

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;

  // [...]
Read more comments on GitHub >

github_iconTop Results From Across the Web

MS Edge broken colors · Issue #417 · debug-js/debug - GitHub
so Edge is falsely detected as "webkit" and, hence, colors are enabled. We just need to disable Edge (and IE) which can be...
Read more >
Broken dark mode and inverted colors!
Broken dark mode and inverted colors! Hi there, I've been sending reports about this issue in "Feedback" of Microsoft Edge DAILY for a...
Read more >
Broken dark mode and inverted colors! : r/edge - Reddit
The main issue is that "Auto Dark Mode for Web Contents" inverts the colors of A LOT of unrelated stuff in almost EVERY-SINGLE-WEBSTIE...
Read more >
Common Microsoft Edge Problems, and How to Fix Them
Having trouble with Microsoft Edge? You may run into issues with the maturing browser, so we provided a list of possible problems and...
Read more >
Colors may not be displayed correctly in web browsers such ...
Web browsers such as Google Chrome and Microsoft Edge are equipped ... A website ' Web color is still broken ' that summarizes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found