Skip to content

Commit

Permalink
RN: Console Stub Parity
Browse files Browse the repository at this point in the history
Summary:
Brings parity to the non-`__DEV__` stub polyfill for `console`.

Changelog:
[General][Added] - Added missing `console` polyfills in release builds.

Reviewed By: ejanzer, RSNara

Differential Revision: D18667335

fbshipit-source-id: 0307d04a136e5f7bb914f18b80441b7a7fae5e5b
  • Loading branch information
yungsters authored and facebook-github-bot committed Nov 23, 2019
1 parent ac3c167 commit b7ab922
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Libraries/polyfills/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,30 @@ if (global.nativeLoggingHook) {
});
}
} else if (!global.console) {
const log = global.print || function consoleLoggingStub() {};
function stub() {}
const log = global.print || stub;

global.console = {
debug: log,
error: log,
info: log,
log: log,
warn: log,
trace: log,
debug: log,
table: log,
warn: log,
assert(expression, label) {
if (!expression) {
log('Assertion failed: ' + label);
}
},
clear: stub,
dir: stub,
dirxml: stub,
group: stub,
groupCollapsed: stub,
groupEnd: stub,
profile: stub,
profileEnd: stub,
table: stub,
};

Object.defineProperty(console, '_isPolyfilled', {
Expand Down

0 comments on commit b7ab922

Please sign in to comment.