From 6b593083edc55d0c37b5e074f416f0b0613fda33 Mon Sep 17 00:00:00 2001 From: Darcy Date: Wed, 4 Mar 2015 10:43:20 -0500 Subject: [PATCH] check that console exists before warning Console is undefined in earlier versions of IE when it is not open. This causes an uncaught exception, and breaks applications in these versions of IE when attempting to warn when the console is closed. Admittedly, console will usually be open when testing in development, but still React should not break the application when it is not. --- src/vendor/core/warning.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vendor/core/warning.js b/src/vendor/core/warning.js index f81bf6e0e0..2d0e9c7eb8 100644 --- a/src/vendor/core/warning.js +++ b/src/vendor/core/warning.js @@ -45,7 +45,9 @@ if (__DEV__) { if (!condition) { var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]); - console.warn(message); + if (typeof console !== 'undefined') { + console.warn(message); + } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack