From 5a38a9f9cc0d839d1eef9ff95d9f813601902607 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 23 Jun 2017 00:29:03 +0200 Subject: [PATCH] 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. --- src/lib/button/button.ts | 6 +----- src/lib/chips/chip.ts | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/lib/button/button.ts b/src/lib/button/button.ts index 22a0f6b0078..c29acbd8bea 100644 --- a/src/lib/button/button.ts +++ b/src/lib/button/button.ts @@ -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'], @@ -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) { diff --git a/src/lib/chips/chip.ts b/src/lib/chips/chip.ts index 3ab000852f3..fc9cf1818a7 100644 --- a/src/lib/chips/chip.ts +++ b/src/lib/chips/chip.ts @@ -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', @@ -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