From 1ab5eb0844c31fd845aab3e3d1c8b21327e18548 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Tue, 2 Aug 2016 07:48:15 -0700 Subject: [PATCH] =?UTF-8?q?refactor(core):=20don=E2=80=99t=20use=20`zone.r?= =?UTF-8?q?un`=20in=20`ApplicationRef.bootstrap`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- modules/@angular/core/src/application_ref.ts | 43 +++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index 9f9dd23666..d7f0f81e21 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -549,30 +549,27 @@ export class ApplicationRef_ extends ApplicationRef { throw new BaseException( '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; - if (componentOrFactory instanceof ComponentFactory) { - componentFactory = componentOrFactory; - } else { - componentFactory = - this._componentFactoryResolver.resolveComponentFactory(componentOrFactory); - } - this._rootComponentTypes.push(componentFactory.componentType); - var compRef = componentFactory.create(this._injector, [], componentFactory.selector); - compRef.onDestroy(() => { this._unloadComponent(compRef); }); - var testability = compRef.injector.get(Testability, null); - if (isPresent(testability)) { - compRef.injector.get(TestabilityRegistry) - .registerApplication(compRef.location.nativeElement, testability); - } + let componentFactory: ComponentFactory; + if (componentOrFactory instanceof ComponentFactory) { + componentFactory = componentOrFactory; + } else { + componentFactory = this._componentFactoryResolver.resolveComponentFactory(componentOrFactory); + } + this._rootComponentTypes.push(componentFactory.componentType); + var compRef = componentFactory.create(this._injector, [], componentFactory.selector); + compRef.onDestroy(() => { this._unloadComponent(compRef); }); + var testability = compRef.injector.get(Testability, null); + if (isPresent(testability)) { + compRef.injector.get(TestabilityRegistry) + .registerApplication(compRef.location.nativeElement, testability); + } - this._loadComponent(compRef); - if (isDevMode()) { - this._console.log( - `Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.`); - } - return compRef; - }); + this._loadComponent(compRef); + if (isDevMode()) { + this._console.log( + `Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.`); + } + return compRef; } /** @internal */