From a6c4490fceb14ad8be3863164b0a112e790e320b Mon Sep 17 00:00:00 2001 From: Bowen Ni Date: Tue, 22 Nov 2016 15:06:09 -0800 Subject: [PATCH] Check if `console.error` is defined --- .../platform-browser/src/browser/tools/common_tools.ts | 3 +-- modules/@angular/upgrade/src/util.ts | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts index 852ffba1b8..24bffe74d4 100644 --- a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts +++ b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts @@ -36,6 +36,7 @@ export class AngularProfiler { constructor(ref: ComponentRef) { this.appRef = ref.injector.get(ApplicationRef); } + // tslint:disable:no-console /** * Exercises change detection in a loop and then prints the average amount of * time in milliseconds how long a single round of change detection takes for @@ -75,9 +76,7 @@ export class AngularProfiler { (window.console.profileEnd)(profileName); } const msPerTick = (end - start) / numTicks; - // tslint:disable-next-line:no-console window.console.log(`ran ${numTicks} change detection cycles`); - // tslint:disable-next-line:no-console window.console.log(`${msPerTick.toFixed(2)} ms per check`); return new ChangeDetectionPerfRecord(msPerTick, numTicks); diff --git a/modules/@angular/upgrade/src/util.ts b/modules/@angular/upgrade/src/util.ts index 744d3a4865..12bf5aa057 100644 --- a/modules/@angular/upgrade/src/util.ts +++ b/modules/@angular/upgrade/src/util.ts @@ -15,7 +15,12 @@ export function stringify(obj: any): string { export function onError(e: any) { // TODO: (misko): We seem to not have a stack trace here! - console.error(e, e.stack); + if (console.error) { + console.error(e, e.stack); + } else { + // tslint:disable-next-line:no-console + console.log(e, e.stack); + } throw e; }