Skip to content

Commit

Permalink
refactor(button, chips): use toString method for aria-disabled (#5278)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devversion authored and jelbourn committed Jun 22, 2017
1 parent 5c9391d commit 5a38a9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class MdButton extends _MdButtonMixinBase implements OnDestroy, CanDisabl
a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab]`,
host: {
'[attr.disabled]': 'disabled || null',
'[attr.aria-disabled]': '_isAriaDisabled',
'[attr.aria-disabled]': 'disabled.toString()',
'(click)': '_haltDisabledEvents($event)',
},
inputs: ['disabled', 'color'],
Expand All @@ -216,10 +216,6 @@ export class MdAnchor extends MdButton {
return this.disabled ? -1 : 0;
}

get _isAriaDisabled(): string {
return this.disabled ? 'true' : 'false';
}

_haltDisabledEvents(event: Event) {
// A disabled button shouldn't apply any actions
if (this.disabled) {
Expand Down
7 changes: 1 addition & 6 deletions src/lib/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MdBasicChip { }
'role': 'option',
'[class.mat-chip-selected]': 'selected',
'[attr.disabled]': 'disabled || null',
'[attr.aria-disabled]': '_isAriaDisabled()',
'[attr.aria-disabled]': 'disabled.toString()',
'(click)': '_handleClick($event)',
'(focus)': '_hasFocus = true',
'(blur)': '_hasFocus = false',
Expand Down Expand Up @@ -109,11 +109,6 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
this.onFocus.emit({chip: this});
}

/** The aria-disabled state for the chip */
_isAriaDisabled(): string {
return String(this.disabled);
}

/** Ensures events fire properly upon click. */
_handleClick(event: Event) {
// Check disabled
Expand Down

0 comments on commit 5a38a9f

Please sign in to comment.