fix(router): check if windows.console exists before using it (#12348)
This commit is contained in:
parent
752edca81b
commit
7886561997
|
@ -77,16 +77,30 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
invoke(el: Node, methodName: string, args: any[]): any { (<any>el)[methodName](...args); }
|
||||
|
||||
// TODO(tbosch): move this into a separate environment class once we have it
|
||||
logError(error: string) { (window.console.error || window.console.log)(error); }
|
||||
logError(error: string): void {
|
||||
if (window.console) {
|
||||
(window.console.error || window.console.log)(error);
|
||||
}
|
||||
}
|
||||
|
||||
log(error: string) { window.console.log(error); }
|
||||
log(error: string): void {
|
||||
if (window.console) {
|
||||
window.console.log && window.console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
logGroup(error: string) {
|
||||
logGroup(error: string): void {
|
||||
if (window.console) {
|
||||
window.console.group && window.console.group(error);
|
||||
this.logError(error);
|
||||
}
|
||||
}
|
||||
|
||||
logGroupEnd() { window.console.groupEnd && window.console.groupEnd(); }
|
||||
logGroupEnd(): void {
|
||||
if (window.console) {
|
||||
window.console.groupEnd && window.console.groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
get attrToPropMap(): any { return _attrToPropMap; }
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {__platform_browser_private__ as r} from '@angular/platform-browser';
|
||||
|
||||
export var getDOM: typeof r.getDOM = r.getDOM;
|
|
@ -8,10 +8,12 @@
|
|||
|
||||
import {APP_BASE_HREF, HashLocationStrategy, Location, LocationStrategy, PathLocationStrategy, PlatformLocation} from '@angular/common';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, APP_BOOTSTRAP_LISTENER, ApplicationRef, Compiler, Inject, Injector, ModuleWithProviders, NgModule, NgModuleFactoryLoader, OpaqueToken, Optional, Provider, SkipSelf, SystemJsNgModuleLoader} from '@angular/core';
|
||||
|
||||
import {Route, Routes} from './config';
|
||||
import {RouterLink, RouterLinkWithHref} from './directives/router_link';
|
||||
import {RouterLinkActive} from './directives/router_link_active';
|
||||
import {RouterOutlet} from './directives/router_outlet';
|
||||
import {getDOM} from './private_import_platform-browser';
|
||||
import {ErrorHandler, Router} from './router';
|
||||
import {ROUTES} from './router_config_loader';
|
||||
import {RouterOutletMap} from './router_outlet_map';
|
||||
|
@ -22,7 +24,6 @@ import {DefaultUrlSerializer, UrlSerializer} from './url_tree';
|
|||
import {flatten} from './utils/collection';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @whatItDoes Contains a list of directives
|
||||
* @stable
|
||||
|
@ -249,11 +250,12 @@ export function setupRouter(
|
|||
}
|
||||
|
||||
if (opts.enableTracing) {
|
||||
const dom = getDOM();
|
||||
router.events.subscribe(e => {
|
||||
console.group(`Router Event: ${(<any>e.constructor).name}`);
|
||||
console.log(e.toString());
|
||||
console.log(e);
|
||||
console.groupEnd();
|
||||
dom.logGroup(`Router Event: ${(<any>e.constructor).name}`);
|
||||
dom.log(e.toString());
|
||||
dom.log(e);
|
||||
dom.logGroupEnd();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"outDir": "../../../dist/packages-dist/router",
|
||||
"paths": {
|
||||
"@angular/core": ["../../../dist/packages-dist/core"],
|
||||
"@angular/platform-browser": ["../../../dist/packages-dist/platform-browser"],
|
||||
"@angular/router": ["../../../dist/packages-dist/router"],
|
||||
"@angular/upgrade/static": ["../../../dist/packages-dist/upgrade/static"]
|
||||
},
|
||||
|
|
|
@ -15,6 +15,7 @@ cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped
|
|||
node --max-old-space-size=3000 dist/tools/@angular/tsc-wrapped/src/main -p modules
|
||||
node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/core/tsconfig-build.json
|
||||
node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/common/tsconfig-build.json
|
||||
node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/platform-browser/tsconfig-build.json
|
||||
node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/router/tsconfig-build.json
|
||||
|
||||
echo 'travis_fold:end:BUILD'
|
||||
|
|
Loading…
Reference in New Issue