Skip to content

Commit 25f593c

Browse files
JeanMechethePunderWoman
authored andcommitted
refactor(common): removengModuleFactory input of NgComponentOutlet (#62838)
This was deprecated by #44815 BREAKING CHANGE: NgModuleFactory has been removed, use NgModule instead. PR Close #62838
1 parent 4dfa6f1 commit 25f593c

File tree

4 files changed

+1
-77
lines changed

4 files changed

+1
-77
lines changed

goldens/public-api/common/index.api.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { Injector } from '@angular/core';
1717
import { IterableDiffers } from '@angular/core';
1818
import { KeyValueDiffers } from '@angular/core';
1919
import { NgIterable } from '@angular/core';
20-
import { NgModuleFactory } from '@angular/core';
2120
import { Observable } from 'rxjs';
2221
import { OnChanges } from '@angular/core';
2322
import { OnDestroy } from '@angular/core';
@@ -503,13 +502,11 @@ export class NgComponentOutlet<T = any> implements OnChanges, DoCheck, OnDestroy
503502
ngComponentOutletInputs?: Record<string, unknown>;
504503
// (undocumented)
505504
ngComponentOutletNgModule?: Type<any>;
506-
// @deprecated (undocumented)
507-
ngComponentOutletNgModuleFactory?: NgModuleFactory<any>;
508505
ngDoCheck(): void;
509506
ngOnChanges(changes: SimpleChanges): void;
510507
ngOnDestroy(): void;
511508
// (undocumented)
512-
static ɵdir: i0.ɵɵDirectiveDeclaration<NgComponentOutlet<any>, "[ngComponentOutlet]", ["ngComponentOutlet"], { "ngComponentOutlet": { "alias": "ngComponentOutlet"; "required": false; }; "ngComponentOutletInputs": { "alias": "ngComponentOutletInputs"; "required": false; }; "ngComponentOutletInjector": { "alias": "ngComponentOutletInjector"; "required": false; }; "ngComponentOutletEnvironmentInjector": { "alias": "ngComponentOutletEnvironmentInjector"; "required": false; }; "ngComponentOutletContent": { "alias": "ngComponentOutletContent"; "required": false; }; "ngComponentOutletNgModule": { "alias": "ngComponentOutletNgModule"; "required": false; }; "ngComponentOutletNgModuleFactory": { "alias": "ngComponentOutletNgModuleFactory"; "required": false; }; }, {}, never, never, true, never>;
509+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgComponentOutlet<any>, "[ngComponentOutlet]", ["ngComponentOutlet"], { "ngComponentOutlet": { "alias": "ngComponentOutlet"; "required": false; }; "ngComponentOutletInputs": { "alias": "ngComponentOutletInputs"; "required": false; }; "ngComponentOutletInjector": { "alias": "ngComponentOutletInjector"; "required": false; }; "ngComponentOutletEnvironmentInjector": { "alias": "ngComponentOutletEnvironmentInjector"; "required": false; }; "ngComponentOutletContent": { "alias": "ngComponentOutletContent"; "required": false; }; "ngComponentOutletNgModule": { "alias": "ngComponentOutletNgModule"; "required": false; }; }, {}, never, never, true, never>;
513510
// (undocumented)
514511
static ɵfac: i0.ɵɵFactoryDeclaration<NgComponentOutlet<any>, never>;
515512
}

goldens/public-api/common/upgrade/index.api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { IterableDiffers } from '@angular/core';
1515
import { KeyValueDiffers } from '@angular/core';
1616
import { ModuleWithProviders } from '@angular/core';
1717
import { NgIterable } from '@angular/core';
18-
import { NgModuleFactory } from '@angular/core';
1918
import { Observable } from 'rxjs';
2019
import { OnChanges } from '@angular/core';
2120
import { OnDestroy } from '@angular/core';

packages/common/src/directives/ng_component_outlet.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ export class NgComponentOutlet<T = any> implements OnChanges, DoCheck, OnDestroy
111111
@Input() ngComponentOutletContent?: any[][];
112112

113113
@Input() ngComponentOutletNgModule?: Type<any>;
114-
/**
115-
* @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead.
116-
*/
117-
@Input() ngComponentOutletNgModuleFactory?: NgModuleFactory<any>;
118114

119115
private _componentRef: ComponentRef<T> | undefined;
120116
private _moduleRef: NgModuleRef<any> | undefined;
@@ -177,10 +173,6 @@ export class NgComponentOutlet<T = any> implements OnChanges, DoCheck, OnDestroy
177173
this.ngComponentOutletNgModule,
178174
getParentInjector(injector),
179175
);
180-
} else if (this.ngComponentOutletNgModuleFactory) {
181-
this._moduleRef = this.ngComponentOutletNgModuleFactory.create(
182-
getParentInjector(injector),
183-
);
184176
} else {
185177
this._moduleRef = undefined;
186178
}

packages/common/test/directives/ng_component_outlet_spec.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,6 @@ describe('insert/remove', () => {
187187
expect(fixture.nativeElement).toHaveText('projected foo');
188188
}));
189189

190-
it('should resolve components from other modules, if supplied as an NgModuleFactory', waitForAsync(() => {
191-
const compiler = TestBed.inject(Compiler);
192-
let fixture = TestBed.createComponent(TestComponent);
193-
194-
fixture.detectChanges();
195-
expect(fixture.nativeElement).toHaveText('');
196-
197-
fixture.componentInstance.ngModuleFactory = compiler.compileModuleSync(TestModule2);
198-
fixture.componentInstance.currentComponent = Module2InjectedComponent;
199-
200-
fixture.detectChanges();
201-
expect(fixture.nativeElement).toHaveText('baz');
202-
}));
203-
204190
it('should resolve components from other modules, if supplied as an NgModule class reference', waitForAsync(() => {
205191
let fixture = TestBed.createComponent(TestComponent);
206192

@@ -214,21 +200,6 @@ describe('insert/remove', () => {
214200
expect(fixture.nativeElement).toHaveText('baz');
215201
}));
216202

217-
it('should clean up moduleRef, if supplied as an NgModuleFactory', waitForAsync(() => {
218-
const compiler = TestBed.inject(Compiler);
219-
const fixture = TestBed.createComponent(TestComponent);
220-
fixture.componentInstance.ngModuleFactory = compiler.compileModuleSync(TestModule2);
221-
fixture.componentInstance.currentComponent = Module2InjectedComponent;
222-
fixture.detectChanges();
223-
224-
const moduleRef = fixture.componentInstance.ngComponentOutlet?.['_moduleRef']!;
225-
spyOn(moduleRef, 'destroy').and.callThrough();
226-
227-
expect(moduleRef.destroy).not.toHaveBeenCalled();
228-
fixture.destroy();
229-
expect(moduleRef.destroy).toHaveBeenCalled();
230-
}));
231-
232203
it('should clean up moduleRef, if supplied as an NgModule class reference', waitForAsync(() => {
233204
const fixture = TestBed.createComponent(TestComponent);
234205
fixture.componentInstance.ngModule = TestModule2;
@@ -243,39 +214,6 @@ describe('insert/remove', () => {
243214
expect(moduleRef.destroy).toHaveBeenCalled();
244215
}));
245216

246-
it("should not re-create moduleRef when it didn't actually change", waitForAsync(() => {
247-
const compiler = TestBed.inject(Compiler);
248-
const fixture = TestBed.createComponent(TestComponent);
249-
250-
fixture.componentInstance.ngModuleFactory = compiler.compileModuleSync(TestModule2);
251-
fixture.componentInstance.currentComponent = Module2InjectedComponent;
252-
fixture.detectChanges();
253-
expect(fixture.nativeElement).toHaveText('baz');
254-
const moduleRef = fixture.componentInstance.ngComponentOutlet?.['_moduleRef'];
255-
256-
fixture.componentInstance.currentComponent = Module2InjectedComponent2;
257-
fixture.detectChanges();
258-
259-
expect(fixture.nativeElement).toHaveText('baz2');
260-
expect(moduleRef).toBe(fixture.componentInstance.ngComponentOutlet?.['_moduleRef']);
261-
}));
262-
263-
it('should re-create moduleRef when changed (NgModuleFactory)', waitForAsync(() => {
264-
const compiler = TestBed.inject(Compiler);
265-
const fixture = TestBed.createComponent(TestComponent);
266-
fixture.componentInstance.ngModuleFactory = compiler.compileModuleSync(TestModule2);
267-
fixture.componentInstance.currentComponent = Module2InjectedComponent;
268-
fixture.detectChanges();
269-
270-
expect(fixture.nativeElement).toHaveText('baz');
271-
272-
fixture.componentInstance.ngModuleFactory = compiler.compileModuleSync(TestModule3);
273-
fixture.componentInstance.currentComponent = Module3InjectedComponent;
274-
fixture.detectChanges();
275-
276-
expect(fixture.nativeElement).toHaveText('bat');
277-
}));
278-
279217
it('should re-create moduleRef when changed (NgModule class reference)', waitForAsync(() => {
280218
const fixture = TestBed.createComponent(TestComponent);
281219
fixture.componentInstance.ngModule = TestModule2;
@@ -438,7 +376,6 @@ const TEST_CMP_TEMPLATE = `<ng-template *ngComponentOutlet="
438376
inputs: inputs;
439377
content: projectables;
440378
ngModule: ngModule;
441-
ngModuleFactory: ngModuleFactory;
442379
"></ng-template>`;
443380
@Component({
444381
selector: 'test-cmp',
@@ -452,7 +389,6 @@ class TestComponent {
452389
inputs?: Record<string, unknown>;
453390
projectables?: any[][];
454391
ngModule?: Type<unknown>;
455-
ngModuleFactory?: NgModuleFactory<unknown>;
456392

457393
get cmpRef(): ComponentRef<any> | undefined {
458394
return this.ngComponentOutlet?.['_componentRef'];

0 commit comments

Comments
 (0)