diff --git a/src/lib/button/button.spec.ts b/src/lib/button/button.spec.ts index 901643347a9b..47fd44458bf2 100644 --- a/src/lib/button/button.spec.ts +++ b/src/lib/button/button.spec.ts @@ -127,6 +127,24 @@ describe('MdButton', () => { fixture.detectChanges(); expect(buttonDebugElement.nativeElement.getAttribute('aria-disabled')).toBe('true'); }); + + it('should not add aria-disabled attribute if disabled is false', () => { + let fixture = TestBed.createComponent(TestApp); + let testComponent = fixture.debugElement.componentInstance; + let buttonDebugElement = fixture.debugElement.query(By.css('a')); + fixture.detectChanges(); + expect(buttonDebugElement.nativeElement.getAttribute('aria-disabled')) + .toBe('false', 'Expect aria-disabled="false"'); + expect(buttonDebugElement.nativeElement.getAttribute('disabled')) + .toBeNull('Expect disabled="false"'); + + testComponent.isDisabled = false; + fixture.detectChanges(); + expect(buttonDebugElement.nativeElement.getAttribute('aria-disabled')) + .toBe('false', 'Expect no aria-disabled'); + expect(buttonDebugElement.nativeElement.getAttribute('disabled')) + .toBeNull('Expect no disabled'); + }); }); // Ripple tests. diff --git a/src/lib/button/button.ts b/src/lib/button/button.ts index 3ea49d04bf70..421b810b22d6 100644 --- a/src/lib/button/button.ts +++ b/src/lib/button/button.ts @@ -43,7 +43,7 @@ export class MdButton { /** Whether the ripple effect on click should be disabled. */ private _disableRipple: boolean = false; - private _disabled: boolean = false; + private _disabled: boolean = null; @Input() get disableRipple() { return this._disableRipple; } @@ -51,7 +51,7 @@ export class MdButton { @Input() get disabled() { return this._disabled; } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value) ? true : null; } constructor(private _elementRef: ElementRef, private _renderer: Renderer) { }