Skip to content

Commit ae76eec

Browse files
jbedardalxhub
authored andcommitted
fix(upgrade): propagate return value of resumeBootstrap (#22754)
Fixes #22723 PR Close #22754
1 parent f43fba6 commit ae76eec

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

packages/upgrade/src/dynamic/upgrade_adapter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,9 @@ export class UpgradeAdapter {
389389
const originalResumeBootstrap: () => void = windowAngular.resumeBootstrap;
390390
windowAngular.resumeBootstrap = function() {
391391
windowAngular.resumeBootstrap = originalResumeBootstrap;
392-
windowAngular.resumeBootstrap.apply(this, arguments);
392+
const r = windowAngular.resumeBootstrap.apply(this, arguments);
393393
resolve();
394+
return r;
394395
};
395396
} else {
396397
resolve();

packages/upgrade/src/static/upgrade_module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class UpgradeModule {
268268
windowAngular.resumeBootstrap = function() {
269269
let args = arguments;
270270
windowAngular.resumeBootstrap = originalResumeBootstrap;
271-
ngZone.run(() => { windowAngular.resumeBootstrap.apply(this, args); });
271+
return ngZone.run(() => windowAngular.resumeBootstrap.apply(this, args));
272272
};
273273
}
274274
}

packages/upgrade/test/dynamic/upgrade_spec.ts

+23
Original file line numberDiff line numberDiff line change
@@ -2909,6 +2909,29 @@ withEachNg1Version(() => {
29092909
}, 100);
29102910
}));
29112911

2912+
it('should propagate return value of resumeBootstrap', fakeAsync(() => {
2913+
@NgModule({imports: [BrowserModule]})
2914+
class MyNg2Module {
2915+
}
2916+
2917+
const adapter: UpgradeAdapter = new UpgradeAdapter(MyNg2Module);
2918+
const ng1Module = angular.module('ng1', []);
2919+
let a1Injector: angular.IInjectorService|undefined;
2920+
ng1Module.run([
2921+
'$injector', function($injector: angular.IInjectorService) { a1Injector = $injector; }
2922+
]);
2923+
2924+
const element = html('<div></div>');
2925+
window.name = 'NG_DEFER_BOOTSTRAP!' + window.name;
2926+
2927+
adapter.bootstrap(element, [ng1Module.name]).ready((ref) => { ref.dispose(); });
2928+
2929+
tick(100);
2930+
2931+
const value = (<any>window).angular.resumeBootstrap();
2932+
expect(value).toBe(a1Injector);
2933+
}));
2934+
29122935
it('should wait for ng2 testability', async(() => {
29132936
@NgModule({imports: [BrowserModule]})
29142937
class MyNg2Module {

packages/upgrade/test/static/integration/testability_spec.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {NgModule, Testability, destroyPlatform} from '@angular/core';
1010
import {NgZone} from '@angular/core/src/zone/ng_zone';
11-
import {fakeAsync, tick} from '@angular/core/testing';
11+
import {fakeAsync, flush, tick} from '@angular/core/testing';
1212
import {BrowserModule} from '@angular/platform-browser';
1313
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
1414
import {UpgradeModule} from '@angular/upgrade/static';
@@ -48,6 +48,25 @@ withEachNg1Version(() => {
4848
expect(stayedInTheZone).toEqual(true);
4949
}));
5050

51+
it('should propagate return value of resumeBootstrap', fakeAsync(() => {
52+
const ng1Module = angular.module('ng1', []);
53+
let a1Injector: angular.IInjectorService|undefined;
54+
ng1Module.run([
55+
'$injector', function($injector: angular.IInjectorService) { a1Injector = $injector; }
56+
]);
57+
const element = html('<div></div>');
58+
window.name = 'NG_DEFER_BOOTSTRAP!' + window.name;
59+
60+
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module);
61+
62+
tick(100);
63+
64+
const value = (<any>window).angular.resumeBootstrap();
65+
expect(value).toBe(a1Injector);
66+
67+
flush();
68+
}));
69+
5170
it('should wait for ng2 testability', fakeAsync(() => {
5271
const ng1Module = angular.module('ng1', []);
5372
const element = html('<div></div>');

0 commit comments

Comments
 (0)