Skip to content

Commit

Permalink
Fix warning without stack for ie9
Browse files Browse the repository at this point in the history
Where console methods like log, error etc. don't have 'apply' method.
Because of the lot of tests already expect that exactly console['method']
will be called - had to reapply references for console.error method

facebook#13610
  • Loading branch information
link-alex committed Sep 12, 2018
1 parent dde0645 commit b18be9e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/shared/warningWithoutStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
let warningWithoutStack = () => {};

if (__DEV__) {
const consoleError = Function.prototype.bind.call(console.error, console);

warningWithoutStack = function(condition, format, ...args) {
if (format === undefined) {
throw new Error(
Expand All @@ -27,7 +29,14 @@ if (__DEV__) {
}
if (typeof console !== 'undefined') {
const stringArgs = args.map(item => '' + item);
const originalConsoleError = console.error;

if (typeof console.error.apply === 'undefined') {
console.error = consoleError;
}

console.error('Warning: ' + format, ...stringArgs);
console.error = originalConsoleError;
}
try {
// --- Welcome to debugging React ---
Expand Down

0 comments on commit b18be9e

Please sign in to comment.