Skip to content

Commit 5a38a9f

Browse files
devversionjelbourn
authored andcommitted
refactor(button, chips): use toString method for aria-disabled (#5278)
For buttons and chips the value of the aria-disabled host binding is resolved from a extra method on the class instance. As already done in other components, the button and chips should just use `boolean.toString()` which is less payload and also makes the code more readable.
1 parent 5c9391d commit 5a38a9f

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/lib/button/button.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class MdButton extends _MdButtonMixinBase implements OnDestroy, CanDisabl
193193
a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab]`,
194194
host: {
195195
'[attr.disabled]': 'disabled || null',
196-
'[attr.aria-disabled]': '_isAriaDisabled',
196+
'[attr.aria-disabled]': 'disabled.toString()',
197197
'(click)': '_haltDisabledEvents($event)',
198198
},
199199
inputs: ['disabled', 'color'],
@@ -216,10 +216,6 @@ export class MdAnchor extends MdButton {
216216
return this.disabled ? -1 : 0;
217217
}
218218

219-
get _isAriaDisabled(): string {
220-
return this.disabled ? 'true' : 'false';
221-
}
222-
223219
_haltDisabledEvents(event: Event) {
224220
// A disabled button shouldn't apply any actions
225221
if (this.disabled) {

src/lib/chips/chip.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class MdBasicChip { }
5555
'role': 'option',
5656
'[class.mat-chip-selected]': 'selected',
5757
'[attr.disabled]': 'disabled || null',
58-
'[attr.aria-disabled]': '_isAriaDisabled()',
58+
'[attr.aria-disabled]': 'disabled.toString()',
5959
'(click)': '_handleClick($event)',
6060
'(focus)': '_hasFocus = true',
6161
'(blur)': '_hasFocus = false',
@@ -109,11 +109,6 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
109109
this.onFocus.emit({chip: this});
110110
}
111111

112-
/** The aria-disabled state for the chip */
113-
_isAriaDisabled(): string {
114-
return String(this.disabled);
115-
}
116-
117112
/** Ensures events fire properly upon click. */
118113
_handleClick(event: Event) {
119114
// Check disabled

0 commit comments

Comments
 (0)