Skip to content

Commit 03c5d34

Browse files
authored
fix(cdk/portal): remove deprecated directives (#32117)
Removes a couple of directives that have been deprecated for a long time. BREAKING CHANGE: * `TemplatePortalDirective` has been removed. Use `CdkPortal` instead. * `PortalHostDirective` has been removed. Use `CdkPortalOutlet` instead.
1 parent fd70015 commit 03c5d34

File tree

5 files changed

+8
-63
lines changed

5 files changed

+8
-63
lines changed

goldens/cdk/portal/index.api.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,14 @@ export abstract class Portal<T> {
111111
setAttachedHost(host: PortalOutlet | null): void;
112112
}
113113

114-
// @public @deprecated (undocumented)
115-
export class PortalHostDirective extends CdkPortalOutlet {
116-
// (undocumented)
117-
static ɵdir: i0.ɵɵDirectiveDeclaration<PortalHostDirective, "[cdkPortalHost], [portalHost]", ["cdkPortalHost"], { "portal": { "alias": "cdkPortalHost"; "required": false; }; }, {}, never, never, true, never>;
118-
// (undocumented)
119-
static ɵfac: i0.ɵɵFactoryDeclaration<PortalHostDirective, never>;
120-
}
121-
122114
// @public (undocumented)
123115
export class PortalModule {
124116
// (undocumented)
125117
static ɵfac: i0.ɵɵFactoryDeclaration<PortalModule, never>;
126118
// (undocumented)
127119
static ɵinj: i0.ɵɵInjectorDeclaration<PortalModule>;
128120
// (undocumented)
129-
static ɵmod: i0.ɵɵNgModuleDeclaration<PortalModule, never, [typeof CdkPortal, typeof CdkPortalOutlet, typeof TemplatePortalDirective, typeof PortalHostDirective], [typeof CdkPortal, typeof CdkPortalOutlet, typeof TemplatePortalDirective, typeof PortalHostDirective]>;
121+
static ɵmod: i0.ɵɵNgModuleDeclaration<PortalModule, never, [typeof CdkPortal, typeof CdkPortalOutlet], [typeof CdkPortal, typeof CdkPortalOutlet]>;
130122
}
131123

132124
// @public
@@ -155,14 +147,6 @@ export class TemplatePortal<C = any> extends Portal<EmbeddedViewRef<C>> {
155147
viewContainerRef: ViewContainerRef;
156148
}
157149

158-
// @public @deprecated (undocumented)
159-
export class TemplatePortalDirective extends CdkPortal {
160-
// (undocumented)
161-
static ɵdir: i0.ɵɵDirectiveDeclaration<TemplatePortalDirective, "[cdk-portal], [portal]", ["cdkPortal"], {}, {}, never, never, true, never>;
162-
// (undocumented)
163-
static ɵfac: i0.ɵɵFactoryDeclaration<TemplatePortalDirective, never>;
164-
}
165-
166150
// (No @packageDocumentation comment for this package)
167151

168152
```

src/cdk/dialog/dialog-module.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ export class DialogModule {}
2929
// See: https://github.com/angular/components/issues/30663.
3030
// Note: These exports need to be stable and shouldn't be renamed unnecessarily because
3131
// consuming libraries might have references to them in their own partial compilation output.
32-
export {
33-
CdkPortal as ɵɵCdkPortal,
34-
CdkPortalOutlet as ɵɵCdkPortalOutlet,
35-
TemplatePortalDirective as ɵɵTemplatePortalDirective,
36-
PortalHostDirective as ɵɵPortalHostDirective,
37-
} from '../portal';
32+
export {CdkPortal as ɵɵCdkPortal, CdkPortalOutlet as ɵɵCdkPortalOutlet} from '../portal';

src/cdk/overlay/fullscreen-overlay-container.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {waitForAsync, TestBed} from '@angular/core/testing';
22
import {Component, ViewChild, ViewContainerRef, inject, DOCUMENT, Injector} from '@angular/core';
33
import {CdkPortal} from '../portal';
44
import {OverlayContainer, FullscreenOverlayContainer, createOverlayRef} from './index';
5-
import {TemplatePortalDirective} from '../portal/portal-directives';
65

76
describe('FullscreenOverlayContainer', () => {
87
let injector: Injector;
@@ -106,8 +105,8 @@ describe('FullscreenOverlayContainer', () => {
106105

107106
/** Test-bed component that contains a TempatePortal and an ElementRef. */
108107
@Component({
109-
template: `<ng-template cdk-portal>Cake</ng-template>`,
110-
imports: [TemplatePortalDirective],
108+
template: `<ng-template cdkPortal>Cake</ng-template>`,
109+
imports: [CdkPortal],
111110
})
112111
class TestComponentWithTemplatePortals {
113112
viewContainerRef = inject(ViewContainerRef);

src/cdk/portal/portal-directives.ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,6 @@ export class CdkPortal extends TemplatePortal {
4444
}
4545
}
4646

47-
/**
48-
* @deprecated Use `CdkPortal` instead.
49-
* @breaking-change 9.0.0
50-
*/
51-
@Directive({
52-
selector: '[cdk-portal], [portal]',
53-
exportAs: 'cdkPortal',
54-
providers: [
55-
{
56-
provide: CdkPortal,
57-
useExisting: TemplatePortalDirective,
58-
},
59-
],
60-
})
61-
export class TemplatePortalDirective extends CdkPortal {}
62-
6347
/**
6448
* Possible attached references to the CdkPortalOutlet.
6549
*/
@@ -234,25 +218,8 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr
234218
}
235219
}
236220

237-
/**
238-
* @deprecated Use `CdkPortalOutlet` instead.
239-
* @breaking-change 9.0.0
240-
*/
241-
@Directive({
242-
selector: '[cdkPortalHost], [portalHost]',
243-
exportAs: 'cdkPortalHost',
244-
inputs: [{name: 'portal', alias: 'cdkPortalHost'}],
245-
providers: [
246-
{
247-
provide: CdkPortalOutlet,
248-
useExisting: PortalHostDirective,
249-
},
250-
],
251-
})
252-
export class PortalHostDirective extends CdkPortalOutlet {}
253-
254221
@NgModule({
255-
imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],
256-
exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],
222+
imports: [CdkPortal, CdkPortalOutlet],
223+
exports: [CdkPortal, CdkPortalOutlet],
257224
})
258225
export class PortalModule {}

src/dev-app/portal/portal-demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ <h2> The portal outlet is here: </h2>
2424
referring to something *in* the template (such as #item in @for). As such, the component
2525
has to use @ViewChild / @ViewChildren to get these references.
2626
See https://github.com/angular/angular/issues/7158 -->
27-
<ng-template cdk-portal>
27+
<ng-template cdkPortal>
2828
<p> - Why don't jokes work in octal?</p>
2929
<p> - Because 7 10 11.</p>
3030
</ng-template>
3131

32-
<div *cdk-portal>
32+
<div *cdkPortal>
3333
<p> - Did you hear about this year's Fibonacci Conference? </p>
3434
<p> - It's going to be as big as the last two put together. </p>
3535
</div>

0 commit comments

Comments
 (0)