@@ -46,37 +46,41 @@ define(function(require) {
4646 if ( typeof console === 'undefined' ) {
4747 log = warn = consoleNotAvailable ;
4848 } else {
49- if ( typeof console . error === 'function'
50- && typeof console . dir === 'function' ) {
49+ // Alias console to prevent things like uglify's drop_console option from
50+ // removing console.log/error. Unhandled rejections fall into the same
51+ // category as uncaught exceptions, and build tools shouldn't silence them.
52+ var localConsole = console ;
53+ if ( typeof localConsole . error === 'function'
54+ && typeof localConsole . dir === 'function' ) {
5155 warn = function ( s ) {
52- console . error ( s ) ;
56+ localConsole . error ( s ) ;
5357 } ;
5458
5559 log = function ( s ) {
56- console . log ( s ) ;
60+ localConsole . log ( s ) ;
5761 } ;
5862
59- if ( typeof console . groupCollapsed === 'function' ) {
63+ if ( typeof localConsole . groupCollapsed === 'function' ) {
6064 groupStart = function ( s ) {
61- console . groupCollapsed ( s ) ;
65+ localConsole . groupCollapsed ( s ) ;
6266 } ;
6367 groupEnd = function ( ) {
64- console . groupEnd ( ) ;
68+ localConsole . groupEnd ( ) ;
6569 } ;
6670 }
6771 } else {
6872 // IE8 has console.log and JSON, so we can make a
6973 // reasonably useful warn() from those.
7074 // Credit to webpro (https://github.com/webpro) for this idea
71- if ( typeof console . log === 'function'
75+ if ( typeof localConsole . log === 'function'
7276 && typeof JSON !== 'undefined' ) {
7377 log = warn = function ( x ) {
7478 if ( typeof x !== 'string' ) {
7579 try {
7680 x = JSON . stringify ( x ) ;
7781 } catch ( e ) { }
7882 }
79- console . log ( x ) ;
83+ localConsole . log ( x ) ;
8084 } ;
8185 }
8286 }
0 commit comments