From 3429584eb39b33ea384ab2bf388ea0148d8d2742 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Mon, 25 Feb 2019 17:57:56 -0800 Subject: [PATCH] refactor(button): use [attr.disabled] host binding in MatButton With ivy, MatAnchor will inherit the host bindings of MatButton. The `[disabled]` binding would then be an error since HTMLAnchorElement does not have a `disabled` property. To work around this, we can simply use the `disabled` attribute instead, which will always be reflected back into the property when it exists. Also add a missing `fixture.detectChanges()` to a test. --- src/lib/button/button.spec.ts | 3 ++- src/lib/button/button.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/button/button.spec.ts b/src/lib/button/button.spec.ts index f23f7f669b60..6f4ed673d244 100644 --- a/src/lib/button/button.spec.ts +++ b/src/lib/button/button.spec.ts @@ -43,8 +43,9 @@ describe('MatButton', () => { it('should expose the ripple instance', () => { const fixture = TestBed.createComponent(TestApp); - const button = fixture.debugElement.query(By.css('button')).componentInstance as MatButton; + fixture.detectChanges(); + const button = fixture.debugElement.query(By.directive(MatButton)).componentInstance; expect(button.ripple).toBeTruthy(); }); diff --git a/src/lib/button/button.ts b/src/lib/button/button.ts index 8b4fcb260b45..96ad9f52ceca 100644 --- a/src/lib/button/button.ts +++ b/src/lib/button/button.ts @@ -70,7 +70,7 @@ export const _MatButtonMixinBase: button[mat-flat-button]`, exportAs: 'matButton', host: { - '[disabled]': 'disabled || null', + '[attr.disabled]': 'disabled || null', '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"', }, templateUrl: 'button.html',