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
This commit is contained in:
Nurzhan Bakibayev 2018-11-07 11:17:18 -08:00 committed by Facebook Github Bot
parent 2a8f6c3028
commit bccc4548e4
1 changed files with 19 additions and 0 deletions

View File

@ -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() {};