From f95a604b59be3b370fd937df9d45cc4201e072ba Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 20 May 2016 11:18:08 -0700 Subject: [PATCH] fix(bootstrap): swap coreBootstrap() and coreLoadAndBootstrap() arguments --- .../compiler_cli/integrationtest/src/bootstrap.ts | 2 +- modules/@angular/core/src/application_ref.ts | 14 +++++++------- modules/@angular/core/test/application_ref_spec.ts | 5 ++--- .../@angular/examples/core/ts/platform/platform.ts | 2 +- .../src/platform/dynamic/browser.ts | 2 +- .../src/platform/dynamic/worker_app.ts | 2 +- .../src/platform/static/browser.ts | 2 +- .../src/platform/static/worker_app.ts | 2 +- .../test/browser/bootstrap_spec.ts | 2 +- .../src/web_workers/todo/server_index.dart | 2 +- 10 files changed, 17 insertions(+), 18 deletions(-) diff --git a/modules/@angular/compiler_cli/integrationtest/src/bootstrap.ts b/modules/@angular/compiler_cli/integrationtest/src/bootstrap.ts index 145415c21c..b9021ceb51 100644 --- a/modules/@angular/compiler_cli/integrationtest/src/bootstrap.ts +++ b/modules/@angular/compiler_cli/integrationtest/src/bootstrap.ts @@ -5,4 +5,4 @@ import {Basic} from './basic'; const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, browserPlatform().injector); -coreBootstrap(appInjector, BasicNgFactory); +coreBootstrap(BasicNgFactory, appInjector); diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index 5ada6bcaed..6a5493f45b 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -51,7 +51,7 @@ export function createPlatform(injector: Injector): PlatformRef { export function assertPlatform(requiredToken: any): PlatformRef { var platform = getPlatform(); if (isBlank(platform)) { - throw new BaseException('Not platform exists!'); + throw new BaseException('No platform exists!'); } if (isPresent(platform) && isBlank(platform.injector.get(requiredToken, null))) { throw new BaseException( @@ -78,10 +78,10 @@ export function getPlatform(): PlatformRef { /** * Shortcut for ApplicationRef.bootstrap. - * Requires a platform the be created first. + * Requires a platform to be created first. */ -export function coreBootstrap(injector: Injector, - componentFactory: ComponentFactory): ComponentRef { +export function coreBootstrap(componentFactory: ComponentFactory, + injector: Injector): ComponentRef { var appRef: ApplicationRef = injector.get(ApplicationRef); return appRef.bootstrap(componentFactory); } @@ -89,10 +89,10 @@ export function coreBootstrap(injector: Injector, /** * Resolves the componentFactory for the given component, * waits for asynchronous initializers and bootstraps the component. - * Requires a platform the be created first. + * Requires a platform to be created first. */ -export function coreLoadAndBootstrap(injector: Injector, - componentType: Type): Promise> { +export function coreLoadAndBootstrap(componentType: Type, + injector: Injector): Promise> { var appRef: ApplicationRef = injector.get(ApplicationRef); return appRef.run(() => { var componentResolver: ComponentResolver = injector.get(ComponentResolver); diff --git a/modules/@angular/core/test/application_ref_spec.ts b/modules/@angular/core/test/application_ref_spec.ts index 1d9f8658a6..6caf6ff3fc 100644 --- a/modules/@angular/core/test/application_ref_spec.ts +++ b/modules/@angular/core/test/application_ref_spec.ts @@ -25,7 +25,6 @@ import { Component, ReflectiveInjector, coreLoadAndBootstrap, - coreBootstrap, PlatformRef, createPlatform, disposePlatform, @@ -114,8 +113,8 @@ export function main() { }, 1); var app = createApplication( [{provide: APP_INITIALIZER, useValue: () => completer.promise, multi: true}]); - coreLoadAndBootstrap(app.injector, MyComp6) - .then((compRef) => { + coreLoadAndBootstrap(MyComp6, app.injector) + .then(_ => { expect(initializerDone).toBe(true); async.done(); }); diff --git a/modules/@angular/examples/core/ts/platform/platform.ts b/modules/@angular/examples/core/ts/platform/platform.ts index f550a43c59..ec75ab1192 100644 --- a/modules/@angular/examples/core/ts/platform/platform.ts +++ b/modules/@angular/examples/core/ts/platform/platform.ts @@ -11,5 +11,5 @@ class MyApp { var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PLATFORM_PROVIDERS)); var appInjector = ReflectiveInjector.resolveAndCreate([BROWSER_APP_STATIC_PROVIDERS, appProviders], platform.injector); -coreLoadAndBootstrap(appInjector, MyApp); +coreLoadAndBootstrap(MyApp, appInjector); // #enddocregion diff --git a/modules/@angular/platform-browser/src/platform/dynamic/browser.ts b/modules/@angular/platform-browser/src/platform/dynamic/browser.ts index a4f33aea96..7ca0eb6bc2 100644 --- a/modules/@angular/platform-browser/src/platform/dynamic/browser.ts +++ b/modules/@angular/platform-browser/src/platform/dynamic/browser.ts @@ -102,5 +102,5 @@ export function bootstrap( var appInjector = ReflectiveInjector.resolveAndCreate( [BROWSER_APP_PROVIDERS, isPresent(customProviders) ? customProviders : []], browserPlatform().injector); - return coreLoadAndBootstrap(appInjector, appComponentType); + return coreLoadAndBootstrap(appComponentType, appInjector); } diff --git a/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts b/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts index daa9d637a8..4dd08fb9a3 100644 --- a/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts +++ b/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts @@ -23,5 +23,5 @@ export function bootstrapApp( var appInjector = ReflectiveInjector.resolveAndCreate( [WORKER_APP_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []], workerAppPlatform().injector); - return coreLoadAndBootstrap(appInjector, appComponentType); + return coreLoadAndBootstrap(appComponentType, appInjector); } diff --git a/modules/@angular/platform-browser/src/platform/static/browser.ts b/modules/@angular/platform-browser/src/platform/static/browser.ts index 57aa0c4d5b..d49639ad0d 100644 --- a/modules/@angular/platform-browser/src/platform/static/browser.ts +++ b/modules/@angular/platform-browser/src/platform/static/browser.ts @@ -30,5 +30,5 @@ export function bootstrapStatic(appComponentType: Type, BROWSER_APP_STATIC_PROVIDERS; var appInjector = ReflectiveInjector.resolveAndCreate(appProviders, browserPlatform().injector); - return coreLoadAndBootstrap(appInjector, appComponentType); + return coreLoadAndBootstrap(appComponentType, appInjector); } diff --git a/modules/@angular/platform-browser/src/platform/static/worker_app.ts b/modules/@angular/platform-browser/src/platform/static/worker_app.ts index 9a6a28a1e0..9e0ed96c10 100644 --- a/modules/@angular/platform-browser/src/platform/static/worker_app.ts +++ b/modules/@angular/platform-browser/src/platform/static/worker_app.ts @@ -29,7 +29,7 @@ export function bootstrapStaticApp( var appInjector = ReflectiveInjector.resolveAndCreate( [WORKER_APP_STATIC_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []], workerAppPlatform().injector); - return coreLoadAndBootstrap(appInjector, appComponentType); + return coreLoadAndBootstrap(appComponentType, appInjector); } function createMessageBus(zone: NgZone): MessageBus { diff --git a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts index d7b1cfa000..b8e20d3a81 100644 --- a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts +++ b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts @@ -214,7 +214,7 @@ export function main() { ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, testProviders], platform.injector) .get(ApplicationRef); - coreLoadAndBootstrap(app.injector, HelloRootCmp) + coreLoadAndBootstrap(HelloRootCmp, app.injector) .then((ref) => { ref.destroy(); expect(() => app.tick()).not.toThrow(); diff --git a/modules/playground/src/web_workers/todo/server_index.dart b/modules/playground/src/web_workers/todo/server_index.dart index 67d4c63287..b2b39cffa3 100644 --- a/modules/playground/src/web_workers/todo/server_index.dart +++ b/modules/playground/src/web_workers/todo/server_index.dart @@ -22,7 +22,7 @@ void main() { new Provider(APP_INITIALIZER, useFactory: initAppThread, multi: true, deps: [NgZone, MessageBus]) ], platform.injector); - coreLoadAndBootstrap(appInjector, TodoApp); + coreLoadAndBootstrap(TodoApp, appInjector); }); }