Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material-experimental/mdc-progress-spinner): fix aria-valuenow #22429

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe we should have a comment here explaining why we're special-casing it? Also do we have to account for aria-valuemin and aria-valuemax?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-valuenmin and aria-valuemax are static and set in the host

// 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) =>
Expand Down