Skip to content

Commit 216759b

Browse files
crisbetojelbourn
authored andcommitted
refactor: expand private getter restrictions to underscored members (#20083)
We have a lint rule that doesn't allow private getters, because they increase the generated ES5 code without much benefit for a private API. These changes expand the restrictions to any public members that are prefixed with an underscore since we don't consider them part of the public API surface. (cherry picked from commit 3dce841)
1 parent 5b63309 commit 216759b

29 files changed

+159
-157
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class CdkDialogContainer extends BasePortalOutlet implements OnDestroy {
8787
// @HostBinding is used in the class as it is expected to be extended. Since @Component decorator
8888
// metadata is not inherited by child classes, instead the host binding data is defined in a way
8989
// that can be inherited.
90-
// tslint:disable:no-host-decorator-in-concrete
90+
// tslint:disable:no-host-decorator-in-concrete no-private-getters
9191
@HostBinding('attr.aria-label') get _ariaLabel() { return this._config.ariaLabel || null; }
9292

9393
@HostBinding('attr.aria-describedby')
@@ -98,7 +98,7 @@ export class CdkDialogContainer extends BasePortalOutlet implements OnDestroy {
9898
@HostBinding('attr.aria-modal') _ariaModal: boolean = true;
9999

100100
@HostBinding('attr.tabindex') get _tabindex() { return -1; }
101-
// tslint:disable:no-host-decorator-in-concrete
101+
// tslint:disable:no-host-decorator-in-concrete no-private-getters
102102

103103
/** The portal host inside of this container into which the dialog content will be loaded. */
104104
@ViewChild(CdkPortalOutlet, {static: true}) _portalHost: CdkPortalOutlet;

src/cdk-experimental/dialog/dialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ export class Dialog implements OnDestroy {
5050
private _scrollStrategy: () => ScrollStrategy;
5151

5252
/** Stream that emits when all dialogs are closed. */
53-
get _afterAllClosed(): Observable<void> {
53+
_getAfterAllClosed(): Observable<void> {
5454
return this._parentDialog ? this._parentDialog.afterAllClosed : this._afterAllClosedBase;
5555
}
5656
_afterAllClosedBase = new Subject<void>();
5757

5858
// TODO(jelbourn): tighten the type on the right-hand side of this expression.
5959
afterAllClosed: Observable<void> = defer(() => this.openDialogs.length ?
60-
this._afterAllClosed : this._afterAllClosed.pipe(startWith(undefined)));
60+
this._getAfterAllClosed() : this._getAfterAllClosed().pipe(startWith(undefined)));
6161

6262
/** Stream that emits when a dialog is opened. */
6363
get afterOpened(): Subject<DialogRef<any>> {

src/cdk/overlay/position/connected-position-strategy.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ export class ConnectedPositionStrategy implements PositionStrategy {
4545

4646
private _direction: Direction | null;
4747

48-
/** Whether the we're dealing with an RTL context */
49-
get _isRtl() {
50-
return this._overlayRef.getDirection() === 'rtl';
51-
}
52-
5348
/** Ordered list of preferred positions, from most to least desirable. */
5449
_preferredPositions: ConnectionPositionPair[] = [];
5550

src/material-experimental/mdc-chips/chip-grid.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,12 @@ describe('MDC-based MatChipGrid', () => {
533533
secondChip.focus();
534534
fixture.detectChanges();
535535

536-
expect(chipGridInstance._chips.toArray().findIndex(chip => chip._hasFocus)).toBe(1);
536+
expect(chipGridInstance._chips.toArray().findIndex(chip => chip._hasFocus())).toBe(1);
537537

538538
dispatchKeyboardEvent(secondChip, 'keydown', DELETE);
539539
fixture.detectChanges();
540540

541-
expect(chipGridInstance._chips.toArray().findIndex(chip => chip._hasFocus)).toBe(1);
541+
expect(chipGridInstance._chips.toArray().findIndex(chip => chip._hasFocus())).toBe(1);
542542
});
543543

544544
describe('when the input has focus', () => {

src/material-experimental/mdc-chips/chip-option.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class MatChipOption extends MatChip implements AfterContentInit {
183183
return;
184184
}
185185

186-
if (!this._hasFocus) {
186+
if (!this._hasFocus()) {
187187
this._elementRef.nativeElement.focus();
188188
this._onFocus.next({chip: this});
189189
}

src/material-experimental/mdc-chips/chip-row.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn
150150
this._hasFocusInternal = false;
151151
// Wait to see if focus moves to the other gridcell
152152
setTimeout(() => {
153-
if (this._hasFocus) {
153+
if (this._hasFocus()) {
154154
return;
155155
}
156156
this._onBlur.next({chip: this});

src/material-experimental/mdc-chips/chip-set.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit
193193

194194
/** Checks whether any of the chips is focused. */
195195
protected _hasFocusedChip() {
196-
return this._chips && this._chips.some(chip => chip._hasFocus);
196+
return this._chips && this._chips.some(chip => chip._hasFocus());
197197
}
198198

199199
/** Syncs the chip-set's state with the individual chips. */
@@ -251,7 +251,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit
251251
// In case the chip that will be removed is currently focused, we temporarily store
252252
// the index in order to be able to determine an appropriate sibling chip that will
253253
// receive focus.
254-
if (this._isValidIndex(chipIndex) && chip._hasFocus) {
254+
if (this._isValidIndex(chipIndex) && chip._hasFocus()) {
255255
this._lastDestroyedChipIndex = chipIndex;
256256
}
257257
});

src/material-experimental/mdc-chips/chip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
158158
this._chipFoundation.handleTransitionEnd(event);
159159
}
160160

161-
get _hasFocus() {
161+
_hasFocus() {
162162
return this._hasFocusInternal;
163163
}
164164

src/material/datepicker/datepicker-base.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,16 @@ export abstract class MatDatepickerBase<C extends MatDatepickerControl<D>, S,
341341
id: string = `mat-datepicker-${datepickerUid++}`;
342342

343343
/** The minimum selectable date. */
344-
get _minDate(): D | null {
344+
_getMinDate(): D | null {
345345
return this._datepickerInput && this._datepickerInput.min;
346346
}
347347

348348
/** The maximum selectable date. */
349-
get _maxDate(): D | null {
349+
_getMaxDate(): D | null {
350350
return this._datepickerInput && this._datepickerInput.max;
351351
}
352352

353-
get _dateFilter(): DateFilterFn<D> {
353+
_getDateFilter(): DateFilterFn<D> {
354354
return this._datepickerInput && this._datepickerInput.dateFilter;
355355
}
356356

src/material/datepicker/datepicker-content.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
[ngClass]="datepicker.panelClass"
44
[startAt]="datepicker.startAt"
55
[startView]="datepicker.startView"
6-
[minDate]="datepicker._minDate"
7-
[maxDate]="datepicker._maxDate"
8-
[dateFilter]="datepicker._dateFilter"
6+
[minDate]="datepicker._getMinDate()"
7+
[maxDate]="datepicker._getMaxDate()"
8+
[dateFilter]="datepicker._getDateFilter()"
99
[headerComponent]="datepicker.calendarHeaderComponent"
1010
[selected]="_getSelected()"
1111
[dateClass]="datepicker.dateClass"

0 commit comments

Comments
 (0)