Skip to content

Commit

Permalink
console polyfill: pass unsupported messages to original console
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Hypuk authored and facebook-github-bot committed Nov 7, 2018
1 parent 2a8f6c3 commit bccc454
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Libraries/polyfills/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};
Expand Down

0 comments on commit bccc454

Please sign in to comment.