refactor(core): don’t use `zone.run` in `ApplicationRef.bootstrap`.
`ApplicationRef.bootstrap` is supposed to be run inside of `ngDoBootstrap` method of the module that is bootstrapped, and that method already runs inside of the zone.
This commit is contained in:
parent
630028350a
commit
1ab5eb0844
|
@ -549,30 +549,27 @@ export class ApplicationRef_ extends ApplicationRef {
|
||||||
throw new BaseException(
|
throw new BaseException(
|
||||||
'Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
'Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
||||||
}
|
}
|
||||||
return this.run(() => {
|
let componentFactory: ComponentFactory<C>;
|
||||||
let componentFactory: ComponentFactory<C>;
|
if (componentOrFactory instanceof ComponentFactory) {
|
||||||
if (componentOrFactory instanceof ComponentFactory) {
|
componentFactory = componentOrFactory;
|
||||||
componentFactory = componentOrFactory;
|
} else {
|
||||||
} else {
|
componentFactory = this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
|
||||||
componentFactory =
|
}
|
||||||
this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
|
this._rootComponentTypes.push(componentFactory.componentType);
|
||||||
}
|
var compRef = componentFactory.create(this._injector, [], componentFactory.selector);
|
||||||
this._rootComponentTypes.push(componentFactory.componentType);
|
compRef.onDestroy(() => { this._unloadComponent(compRef); });
|
||||||
var compRef = componentFactory.create(this._injector, [], componentFactory.selector);
|
var testability = compRef.injector.get(Testability, null);
|
||||||
compRef.onDestroy(() => { this._unloadComponent(compRef); });
|
if (isPresent(testability)) {
|
||||||
var testability = compRef.injector.get(Testability, null);
|
compRef.injector.get(TestabilityRegistry)
|
||||||
if (isPresent(testability)) {
|
.registerApplication(compRef.location.nativeElement, testability);
|
||||||
compRef.injector.get(TestabilityRegistry)
|
}
|
||||||
.registerApplication(compRef.location.nativeElement, testability);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._loadComponent(compRef);
|
this._loadComponent(compRef);
|
||||||
if (isDevMode()) {
|
if (isDevMode()) {
|
||||||
this._console.log(
|
this._console.log(
|
||||||
`Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.`);
|
`Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.`);
|
||||||
}
|
}
|
||||||
return compRef;
|
return compRef;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
|
Loading…
Reference in New Issue