From bd9faa1289fad6557bfcad7f7db0fb49d9921871 Mon Sep 17 00:00:00 2001 From: Alfonso de la Osa Date: Mon, 12 Dec 2016 07:23:39 +0000 Subject: [PATCH] allow colours in workers (#335) --- browser.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index 016189a7..3f63ab23 100644 --- a/browser.js +++ b/browser.js @@ -42,10 +42,12 @@ function useColors() { // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || + (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /**