From 6c64f2e0b890e711f6006e0c3921eeba28755bcf Mon Sep 17 00:00:00 2001 From: Annie Wang Date: Thu, 8 Apr 2021 10:26:10 -0700 Subject: [PATCH] fix(material-experimental/mdc-progress-spinner): fix aria-valuenow --- .../mdc-progress-spinner/progress-spinner.spec.ts | 2 +- .../mdc-progress-spinner/progress-spinner.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/material-experimental/mdc-progress-spinner/progress-spinner.spec.ts b/src/material-experimental/mdc-progress-spinner/progress-spinner.spec.ts index 0fdfc6be3c8f..9dd797a64509 100644 --- a/src/material-experimental/mdc-progress-spinner/progress-spinner.spec.ts +++ b/src/material-experimental/mdc-progress-spinner/progress-spinner.spec.ts @@ -323,7 +323,7 @@ describe('MDC-based MatProgressSpinner', () => { fixture.componentInstance.value = 37; fixture.detectChanges(); - expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('0.37'); + expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('37'); }); it('should clear `aria-valuenow` in indeterminate mode', () => { diff --git a/src/material-experimental/mdc-progress-spinner/progress-spinner.ts b/src/material-experimental/mdc-progress-spinner/progress-spinner.ts index f1d4e7afe586..9f0cad86c5f8 100644 --- a/src/material-experimental/mdc-progress-spinner/progress-spinner.ts +++ b/src/material-experimental/mdc-progress-spinner/progress-spinner.ts @@ -95,8 +95,14 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements hasClass: (className: string) => this._elementRef.nativeElement.classList.contains(className), removeClass: (className: string) => this._elementRef.nativeElement.classList.remove(className), removeAttribute: (name: string) => this._elementRef.nativeElement.removeAttribute(name), - setAttribute: (name: string, value: string) => - this._elementRef.nativeElement.setAttribute(name, value), + setAttribute: (name, value) => { + if (name !== 'aria-valuenow') { + // MDC deals with values between 0 and 1 but Angular Material deals with values between + // 0 and 100 so the aria-valuenow should be set through the attr binding in the host + // instead of by the MDC adapter + this._elementRef.nativeElement.setAttribute(name, value); + } + }, getDeterminateCircleAttribute: (attributeName: string) => this._determinateCircle.nativeElement.getAttribute(attributeName), setDeterminateCircleAttribute: (attributeName: string, value: string) =>