Skip to content

Commit a1fb9f9

Browse files
committed
refactor(cdk/text-field): switch to input transforms
Switches inputs in cdk/text-field to use transforms instead of getters/setters.
1 parent dd04fe9 commit a1fb9f9

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/cdk/text-field/autosize.ts

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

9-
import {
10-
BooleanInput,
11-
coerceBooleanProperty,
12-
coerceNumberProperty,
13-
NumberInput,
14-
} from '@angular/cdk/coercion';
9+
import {NumberInput, coerceNumberProperty} from '@angular/cdk/coercion';
1510
import {
1611
Directive,
1712
ElementRef,
@@ -22,6 +17,7 @@ import {
2217
NgZone,
2318
Optional,
2419
Inject,
20+
booleanAttribute,
2521
} from '@angular/core';
2622
import {Platform} from '@angular/cdk/platform';
2723
import {auditTime, takeUntil} from 'rxjs/operators';
@@ -80,13 +76,11 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
8076
}
8177

8278
/** Whether autosizing is enabled or not */
83-
@Input('cdkTextareaAutosize')
79+
@Input({alias: 'cdkTextareaAutosize', transform: booleanAttribute})
8480
get enabled(): boolean {
8581
return this._enabled;
8682
}
87-
set enabled(value: BooleanInput) {
88-
value = coerceBooleanProperty(value);
89-
83+
set enabled(value: boolean) {
9084
// Only act if the actual value changed. This specifically helps to not run
9185
// resizeToFitContent too early (i.e. before ngAfterViewInit)
9286
if (this._enabled !== value) {

tools/public_api_guard/cdk/text-field.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
```ts
66

77
import { AfterViewInit } from '@angular/core';
8-
import { BooleanInput } from '@angular/cdk/coercion';
98
import { DoCheck } from '@angular/core';
109
import { ElementRef } from '@angular/core';
1110
import { EventEmitter } from '@angular/core';
@@ -58,12 +57,14 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
5857
document?: any);
5958
protected _document?: Document;
6059
get enabled(): boolean;
61-
set enabled(value: BooleanInput);
60+
set enabled(value: boolean);
6261
get maxRows(): number;
6362
set maxRows(value: NumberInput);
6463
get minRows(): number;
6564
set minRows(value: NumberInput);
6665
// (undocumented)
66+
static ngAcceptInputType_enabled: unknown;
67+
// (undocumented)
6768
ngAfterViewInit(): void;
6869
// (undocumented)
6970
ngDoCheck(): void;

0 commit comments

Comments
 (0)