Skip to content

Commit 768534d

Browse files
authored
fix(material-experimental/mdc-progress-spinner): fix aria-valuenow (#22429)
1 parent 9b4c503 commit 768534d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/material-experimental/mdc-progress-spinner/progress-spinner.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe('MDC-based MatProgressSpinner', () => {
323323
fixture.componentInstance.value = 37;
324324
fixture.detectChanges();
325325

326-
expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('0.37');
326+
expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('37');
327327
});
328328

329329
it('should clear `aria-valuenow` in indeterminate mode', () => {

src/material-experimental/mdc-progress-spinner/progress-spinner.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
9595
hasClass: (className: string) => this._elementRef.nativeElement.classList.contains(className),
9696
removeClass: (className: string) => this._elementRef.nativeElement.classList.remove(className),
9797
removeAttribute: (name: string) => this._elementRef.nativeElement.removeAttribute(name),
98-
setAttribute: (name: string, value: string) =>
99-
this._elementRef.nativeElement.setAttribute(name, value),
98+
setAttribute: (name, value) => {
99+
if (name !== 'aria-valuenow') {
100+
// MDC deals with values between 0 and 1 but Angular Material deals with values between
101+
// 0 and 100 so the aria-valuenow should be set through the attr binding in the host
102+
// instead of by the MDC adapter
103+
this._elementRef.nativeElement.setAttribute(name, value);
104+
}
105+
},
100106
getDeterminateCircleAttribute: (attributeName: string) =>
101107
this._determinateCircle.nativeElement.getAttribute(attributeName),
102108
setDeterminateCircleAttribute: (attributeName: string, value: string) =>

0 commit comments

Comments
 (0)