Skip to content

Commit 4d47552

Browse files
committed
refactor(multiple): clean up more ViewEngine-specific code
Cleans up a bunch of workarounds and docs that were specific to ViewEngine. There are still more places to clean up, but I'm trying to make it easier to track down any potential failures.
1 parent d4a6c3b commit 4d47552

File tree

24 files changed

+15
-229
lines changed

24 files changed

+15
-229
lines changed

src/cdk-experimental/dialog/dialog-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ import {
3737
{provide: DIALOG_CONTAINER, useValue: CdkDialogContainer},
3838
{provide: DIALOG_CONFIG, useValue: DialogConfig},
3939
],
40-
entryComponents: [CdkDialogContainer],
4140
})
4241
export class DialogModule {}

src/cdk/drag-drop/directives/drag.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,17 +4698,6 @@ describe('CdkDrag', () => {
46984698
}));
46994699

47004700
it('should be able to start dragging again if the dragged item is destroyed', fakeAsync(() => {
4701-
// We have some behavior where we move the dragged element out to the bottom of the `body`,
4702-
// in order to work around a browser issue. We restore the element when dragging stops, but
4703-
// the problem is that if it's destroyed before we've had a chance to return it, ViewEngine
4704-
// will throw an error since the element isn't in its original parent. Skip this test if the
4705-
// component hasn't been compiled with Ivy since the assertions depend on the element being
4706-
// removed while dragging.
4707-
// TODO(crisbeto): remove this check once ViewEngine has been dropped.
4708-
if (!DraggableInDropZone.hasOwnProperty('ɵcmp')) {
4709-
return;
4710-
}
4711-
47124701
const fixture = createComponent(DraggableInDropZone);
47134702
fixture.detectChanges();
47144703

src/cdk/portal/portal.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ A component can use `@ViewChild` or `@ViewChildren` to get a reference to a
5050
`CdkPortal`.
5151

5252
##### `ComponentPortal`
53-
Used to create a portal from a component type. When a component is dynamically created using
54-
portals, it must be included in the `entryComponents` of its `NgModule`if your project uses ViewEngine. Projects
55-
using Angular Ivy don't need `entryComponents`.
53+
Used to create a portal from a component type.
5654

5755
Usage:
5856
```ts

src/dev-app/main-module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import {ANIMATIONS_STORAGE_KEY} from './dev-app/dev-app-layout';
2424
@NgModule({
2525
imports: [
2626
BrowserAnimationsModule.withConfig({
27-
// Note that this doesn't seem to work on ViewEngine, but it's
28-
// not a compilation error either so we can live with it.
2927
disableAnimations: localStorage.getItem(ANIMATIONS_STORAGE_KEY) === 'true',
3028
}),
3129
BrowserModule,

src/material-experimental/column-resize/column-resize-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const ENTRY_COMMON_COMPONENTS = [MatColumnResizeOverlayHandle];
2323
@NgModule({
2424
declarations: ENTRY_COMMON_COMPONENTS,
2525
exports: ENTRY_COMMON_COMPONENTS,
26-
entryComponents: ENTRY_COMMON_COMPONENTS,
2726
})
2827
export class MatColumnResizeCommonModule {}
2928

src/material-experimental/mdc-button/fab.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,11 @@ const defaults = MAT_FAB_DEFAULT_OPTIONS_FACTORY();
6666
selector: `button[mat-fab]`,
6767
templateUrl: 'button.html',
6868
styleUrls: ['fab.css'],
69-
// TODO: change to MAT_BUTTON_INPUTS/MAT_BUTTON_HOST with spread after ViewEngine is deprecated
70-
inputs: ['disabled', 'disableRipple', 'color', 'extended'],
69+
inputs: [...MAT_BUTTON_INPUTS, 'extended'],
7170
host: {
71+
...MAT_BUTTON_HOST,
7272
'[class.mdc-fab--extended]': 'extended',
7373
'[class.mat-mdc-extended-fab]': 'extended',
74-
'[attr.disabled]': 'disabled || null',
75-
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
76-
// MDC automatically applies the primary theme color to the button, but we want to support
77-
// an unthemed version. If color is undefined, apply a CSS class that makes it easy to
78-
// select and style this "theme".
79-
'[class.mat-unthemed]': '!color',
80-
// Add a class that applies to all buttons. This makes it easier to target if somebody
81-
// wants to target all Material buttons.
82-
'[class.mat-mdc-button-base]': 'true',
8374
},
8475
exportAs: 'matButton',
8576
encapsulation: ViewEncapsulation.None,
@@ -153,26 +144,11 @@ export class MatMiniFabButton extends MatButtonBase {
153144
selector: `a[mat-fab]`,
154145
templateUrl: 'button.html',
155146
styleUrls: ['fab.css'],
156-
// TODO: change to MAT_ANCHOR_INPUTS/MAT_ANCHOR_HOST with spread after ViewEngine is deprecated
157-
inputs: ['disabled', 'disableRipple', 'color', 'tabIndex', 'extended'],
147+
inputs: [...MAT_BUTTON_INPUTS, 'extended'],
158148
host: {
149+
...MAT_ANCHOR_HOST,
159150
'[class.mdc-fab--extended]': 'extended',
160151
'[class.mat-mdc-extended-fab]': 'extended',
161-
'[attr.disabled]': 'disabled || null',
162-
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
163-
164-
// Note that we ignore the user-specified tabindex when it's disabled for
165-
// consistency with the `mat-button` applied on native buttons where even
166-
// though they have an index, they're not tabbable.
167-
'[attr.tabindex]': 'disabled ? -1 : (tabIndex || 0)',
168-
'[attr.aria-disabled]': 'disabled.toString()',
169-
// MDC automatically applies the primary theme color to the button, but we want to support
170-
// an unthemed version. If color is undefined, apply a CSS class that makes it easy to
171-
// select and style this "theme".
172-
'[class.mat-unthemed]': '!color',
173-
// Add a class that applies to all buttons. This makes it easier to target if somebody
174-
// wants to target all Material buttons.
175-
'[class.mat-mdc-button-base]': 'true',
176152
},
177153
exportAs: 'matButton, matAnchor',
178154
encapsulation: ViewEncapsulation.None,

src/material-experimental/mdc-dialog/module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ import {
3737
MatDialogContent,
3838
],
3939
providers: [MatDialog, MAT_DIALOG_SCROLL_STRATEGY_PROVIDER],
40-
entryComponents: [MatDialogContainer],
4140
})
4241
export class MatDialogModule {}

src/material-experimental/mdc-snack-bar/module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ import {MatSnackBarAction, MatSnackBarActions, MatSnackBarLabel} from './snack-b
3333
MatSnackBarActions,
3434
MatSnackBarAction,
3535
],
36-
entryComponents: [MatSimpleSnackBar, MatSnackBarContainer],
3736
})
3837
export class MatSnackBarModule {}

src/material-experimental/mdc-tooltip/module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {MatTooltip, TooltipComponent} from './tooltip';
1919
imports: [A11yModule, CommonModule, OverlayModule, MatCommonModule],
2020
exports: [MatTooltip, TooltipComponent, MatCommonModule, CdkScrollableModule],
2121
declarations: [MatTooltip, TooltipComponent],
22-
entryComponents: [TooltipComponent],
2322
providers: [MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER],
2423
})
2524
export class MatTooltipModule {}

src/material-experimental/selection/row-selection.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {coerceNumberProperty} from '@angular/cdk/coercion';
109
import {CdkRowSelection} from '@angular/cdk-experimental/selection';
1110
import {Input, Directive} from '@angular/core';
1211

@@ -24,20 +23,9 @@ import {Input, Directive} from '@angular/core';
2423
'[attr.aria-selected]': '_selection.isSelected(this.value, this.index)',
2524
},
2625
providers: [{provide: CdkRowSelection, useExisting: MatRowSelection}],
26+
inputs: ['index: matRowSelectionIndex'],
2727
})
28-
// tslint:disable-next-line: coercion-types
2928
export class MatRowSelection<T> extends CdkRowSelection<T> {
3029
/** The value that is associated with the row */
3130
@Input('matRowSelectionValue') override value: T;
32-
33-
/** The index of the value in the list. Required when used with `trackBy` */
34-
@Input('matRowSelectionIndex')
35-
override get index(): number | undefined {
36-
return this._index;
37-
}
38-
override set index(index: number | undefined) {
39-
// TODO: when we remove support for ViewEngine, change this setter to an input
40-
// alias in the decorator metadata.
41-
this._index = coerceNumberProperty(index);
42-
}
4331
}

src/material-experimental/selection/selection-toggle.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {coerceNumberProperty} from '@angular/cdk/coercion';
109
import {CdkSelectionToggle} from '@angular/cdk-experimental/selection';
1110
import {Directive, Input} from '@angular/core';
1211

@@ -23,21 +22,10 @@ import {Directive, Input} from '@angular/core';
2322
@Directive({
2423
selector: '[matSelectionToggle]',
2524
exportAs: 'matSelectionToggle',
25+
inputs: ['index: matSelectionToggleIndex'],
2626
providers: [{provide: CdkSelectionToggle, useExisting: MatSelectionToggle}],
2727
})
28-
// tslint:disable-next-line: coercion-types
2928
export class MatSelectionToggle<T> extends CdkSelectionToggle<T> {
3029
/** The value that is associated with the toggle */
3130
@Input('matSelectionToggleValue') override value: T;
32-
33-
/** The index of the value in the list. Required when used with `trackBy` */
34-
@Input('matSelectionToggleIndex')
35-
override get index(): number | undefined {
36-
return this._index;
37-
}
38-
override set index(index: number | undefined) {
39-
// TODO: when we remove support for ViewEngine, change this setter to an input
40-
// alias in the decorator metadata.
41-
this._index = coerceNumberProperty(index);
42-
}
4331
}

src/material/bottom-sheet/bottom-sheet-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ import {MatBottomSheetContainer} from './bottom-sheet-container';
1616
imports: [OverlayModule, MatCommonModule, PortalModule],
1717
exports: [MatBottomSheetContainer, MatCommonModule],
1818
declarations: [MatBottomSheetContainer],
19-
entryComponents: [MatBottomSheetContainer],
2019
})
2120
export class MatBottomSheetModule {}

src/material/bottom-sheet/bottom-sheet.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,6 @@ export class HobbitSheet {
4949
}
5050
```
5151

52-
### Configuring bottom sheet content via `entryComponents`
53-
**You only need to specify `entryComponents` if your project uses ViewEngine. Projects
54-
using Angular Ivy don't need `entryComponents`.**
55-
56-
Similarly to `MatDialog`, `MatBottomSheet` instantiates components at run-time. In order for it to
57-
work, the Angular compiler needs extra information to create the necessary `ComponentFactory` for
58-
your bottom sheet content component.
59-
60-
Any components that are included inside of a bottom sheet have to be added to the `entryComponents`
61-
inside your `NgModule`.
62-
63-
64-
```ts
65-
@NgModule({
66-
imports: [
67-
// ...
68-
MatBottomSheetModule
69-
],
70-
71-
declarations: [
72-
AppComponent,
73-
ExampleBottomSheetComponent
74-
],
75-
76-
entryComponents: [
77-
ExampleBottomSheetComponent
78-
],
79-
80-
bootstrap: [AppComponent]
81-
})
82-
export class AppModule {}
83-
```
84-
8552
### Specifying global configuration defaults
8653
Default bottom sheet options can be specified by providing an instance of `MatBottomSheetConfig`
8754
for `MAT_BOTTOM_SHEET_DEFAULT_OPTIONS` in your application's root module.

src/material/datepicker/date-range-input-parts.ts

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ const _MatDateRangeInputBase = mixinErrorState(MatDateRangeInputPartBase);
208208
outputs: ['dateChange', 'dateInput'],
209209
inputs: ['errorStateMatcher'],
210210
})
211-
export class MatStartDate<D>
212-
extends _MatDateRangeInputBase<D>
213-
implements CanUpdateErrorState, DoCheck, OnInit
214-
{
211+
export class MatStartDate<D> extends _MatDateRangeInputBase<D> implements CanUpdateErrorState {
215212
/** Validator that checks that the start date isn't after the end date. */
216213
private _startValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
217214
const start = this._dateAdapter.getValidDateOrNull(
@@ -233,9 +230,6 @@ export class MatStartDate<D>
233230
@Optional() dateAdapter: DateAdapter<D>,
234231
@Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats,
235232
) {
236-
// TODO(crisbeto): this constructor shouldn't be necessary, but ViewEngine doesn't seem to
237-
// handle DI correctly when it is inherited from `MatDateRangeInputPartBase`. We can drop this
238-
// constructor once ViewEngine is removed.
239233
super(
240234
rangeInput,
241235
elementRef,
@@ -248,26 +242,6 @@ export class MatStartDate<D>
248242
);
249243
}
250244

251-
override ngOnInit() {
252-
// Normally this happens automatically, but it seems to break if not added explicitly when all
253-
// of the criteria below are met:
254-
// 1) The class extends a TS mixin.
255-
// 2) The application is running in ViewEngine.
256-
// 3) The application is being transpiled through tsickle.
257-
// This can be removed once google3 is completely migrated to Ivy.
258-
super.ngOnInit();
259-
}
260-
261-
override ngDoCheck() {
262-
// Normally this happens automatically, but it seems to break if not added explicitly when all
263-
// of the criteria below are met:
264-
// 1) The class extends a TS mixin.
265-
// 2) The application is running in ViewEngine.
266-
// 3) The application is being transpiled through tsickle.
267-
// This can be removed once google3 is completely migrated to Ivy.
268-
super.ngDoCheck();
269-
}
270-
271245
protected _validator = Validators.compose([...super._getValidators(), this._startValidator]);
272246

273247
protected _getValueFromModel(modelValue: DateRange<D>) {
@@ -334,10 +308,7 @@ export class MatStartDate<D>
334308
outputs: ['dateChange', 'dateInput'],
335309
inputs: ['errorStateMatcher'],
336310
})
337-
export class MatEndDate<D>
338-
extends _MatDateRangeInputBase<D>
339-
implements CanUpdateErrorState, DoCheck, OnInit
340-
{
311+
export class MatEndDate<D> extends _MatDateRangeInputBase<D> implements CanUpdateErrorState {
341312
/** Validator that checks that the end date isn't before the start date. */
342313
private _endValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
343314
const end = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
@@ -357,9 +328,6 @@ export class MatEndDate<D>
357328
@Optional() dateAdapter: DateAdapter<D>,
358329
@Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats,
359330
) {
360-
// TODO(crisbeto): this constructor shouldn't be necessary, but ViewEngine doesn't seem to
361-
// handle DI correctly when it is inherited from `MatDateRangeInputPartBase`. We can drop this
362-
// constructor once ViewEngine is removed.
363331
super(
364332
rangeInput,
365333
elementRef,
@@ -372,26 +340,6 @@ export class MatEndDate<D>
372340
);
373341
}
374342

375-
override ngOnInit() {
376-
// Normally this happens automatically, but it seems to break if not added explicitly when all
377-
// of the criteria below are met:
378-
// 1) The class extends a TS mixin.
379-
// 2) The application is running in ViewEngine.
380-
// 3) The application is being transpiled through tsickle.
381-
// This can be removed once google3 is completely migrated to Ivy.
382-
super.ngOnInit();
383-
}
384-
385-
override ngDoCheck() {
386-
// Normally this happens automatically, but it seems to break if not added explicitly when all
387-
// of the criteria below are met:
388-
// 1) The class extends a TS mixin.
389-
// 2) The application is running in ViewEngine.
390-
// 3) The application is being transpiled through tsickle.
391-
// This can be removed once google3 is completely migrated to Ivy.
392-
super.ngDoCheck();
393-
}
394-
395343
protected _validator = Validators.compose([...super._getValidators(), this._endValidator]);
396344

397345
protected _getValueFromModel(modelValue: DateRange<D>) {

src/material/datepicker/datepicker-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,5 @@ import {MatDatepickerActions, MatDatepickerApply, MatDatepickerCancel} from './d
8383
MatDatepickerApply,
8484
],
8585
providers: [MatDatepickerIntl, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER],
86-
entryComponents: [MatDatepickerContent, MatCalendarHeader],
8786
})
8887
export class MatDatepickerModule {}

src/material/dialog/dialog-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ import {
3737
MatDialogContent,
3838
],
3939
providers: [MatDialog, MAT_DIALOG_SCROLL_STRATEGY_PROVIDER],
40-
entryComponents: [MatDialogContainer],
4140
})
4241
export class MatDialogModule {}

src/material/dialog/dialog.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,6 @@ export class YourDialog {
3939
}
4040
```
4141

42-
### Configuring dialog content via `entryComponents`
43-
**You only need to specify `entryComponents` if your project uses ViewEngine. Projects
44-
using Angular Ivy don't need `entryComponents`.**
45-
46-
Because `MatDialog` instantiates components at run-time, the Angular compiler needs extra
47-
information to create the necessary `ComponentFactory` for your dialog content component.
48-
49-
For any component loaded into a dialog, you must include your component class in the list of
50-
`entryComponents` in your NgModule definition so that the Angular compiler knows to create
51-
the `ComponentFactory` for it.
52-
53-
```ts
54-
@NgModule({
55-
imports: [
56-
// ...
57-
MatDialogModule
58-
],
59-
60-
declarations: [
61-
AppComponent,
62-
ExampleDialogComponent
63-
],
64-
65-
entryComponents: [
66-
ExampleDialogComponent
67-
],
68-
69-
bootstrap: [AppComponent]
70-
})
71-
export class AppModule {}
72-
```
73-
7442
### Specifying global configuration defaults
7543
Default dialog options can be specified by providing an instance of `MatDialogConfig` for
7644
MAT_DIALOG_DEFAULT_OPTIONS in your application's root module.
@@ -194,5 +162,5 @@ sheet attempts to restore focus.
194162
You can add handling for this situation with the `afterClosed()` observable from `MatDialogRef`.
195163

196164
<!-- example({"example":"dialog-from-menu",
197-
"file":"dialog-from-menu-example.ts",
165+
"file":"dialog-from-menu-example.ts",
198166
"region":"focus-restoration"}) -->

src/material/snack-bar/snack-bar-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ import {MatSnackBarContainer} from './snack-bar-container';
1919
imports: [OverlayModule, PortalModule, CommonModule, MatButtonModule, MatCommonModule],
2020
exports: [MatSnackBarContainer, MatCommonModule],
2121
declarations: [MatSnackBarContainer, SimpleSnackBar],
22-
entryComponents: [MatSnackBarContainer, SimpleSnackBar],
2322
})
2423
export class MatSnackBarModule {}

0 commit comments

Comments
 (0)