From bccc4548e4d22b275f28a9beaf573f74d8b69213 Mon Sep 17 00:00:00 2001 From: Nurzhan Bakibayev Date: Wed, 7 Nov 2018 11:17:18 -0800 Subject: [PATCH] console polyfill: pass unsupported messages to original console Summary: Some console methods (like `groupCollapsed` or `clear`) are not supported by console.js polyfill and are not passed to the original console objects. Reviewed By: sahrens Differential Revision: D12900996 fbshipit-source-id: 1b2f487028e418ae934f631996eaaf63abdced82 --- Libraries/polyfills/console.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Libraries/polyfills/console.js b/Libraries/polyfills/console.js index e8c4a7dbc..661679bf8 100644 --- a/Libraries/polyfills/console.js +++ b/Libraries/polyfills/console.js @@ -558,6 +558,25 @@ if (global.nativeLoggingHook) { }; } }); + + // The following methods are not supported by this polyfill but + // we still should pass them to original console if they are + // supported by it. + [ + 'assert', + 'clear', + 'dir', + 'dirxml', + 'groupCollapsed', + 'profile', + 'profileEnd', + ].forEach(methodName => { + if (typeof originalConsole[methodName] === 'function') { + console[methodName] = function() { + originalConsole[methodName](...arguments); + }; + } + }); } } else if (!global.console) { const log = global.print || function consoleLoggingStub() {};