fix(progress-spinner): clear aria-valuenow in indeterminate mode (#15052)

Clears the `aria-valuenow` attribute when the progress spinner is in indeterminate mode, [based on the a11y spec](https://www.w3.org/TR/wai-aria-1.1/#progressbar).

Fixes #15018.
This commit is contained in:
Kristiyan Kostadinov
2019-02-22 16:06:24 +01:00
committed by Jeremy Elbourn
parent a88d053395
commit dd4257eaca
2 changed files with 26 additions and 1 deletions
@@ -296,6 +296,31 @@ describe('MatProgressSpinner', () => {
expect(progressElement.componentInstance.strokeWidth).toBe(7);
});
it('should set `aria-valuenow` to the current value in determinate mode', () => {
const fixture = TestBed.createComponent(ProgressSpinnerWithValueAndBoundMode);
const progressElement = fixture.debugElement.query(By.css('mat-progress-spinner'));
fixture.componentInstance.mode = 'determinate';
fixture.componentInstance.value = 37;
fixture.detectChanges();
expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('37');
});
it('should clear `aria-valuenow` in indeterminate mode', () => {
const fixture = TestBed.createComponent(ProgressSpinnerWithValueAndBoundMode);
const progressElement = fixture.debugElement.query(By.css('mat-progress-spinner'));
fixture.componentInstance.mode = 'determinate';
fixture.componentInstance.value = 89;
fixture.detectChanges();
expect(progressElement.nativeElement.hasAttribute('aria-valuenow')).toBe(true);
fixture.componentInstance.mode = 'indeterminate';
fixture.detectChanges();
expect(progressElement.nativeElement.hasAttribute('aria-valuenow')).toBe(false);
});
});
+1 -1
View File
@@ -114,7 +114,7 @@ const INDETERMINATE_ANIMATION_TEMPLATE = `
'[style.height.px]': 'diameter',
'[attr.aria-valuemin]': 'mode === "determinate" ? 0 : null',
'[attr.aria-valuemax]': 'mode === "determinate" ? 100 : null',
'[attr.aria-valuenow]': 'value',
'[attr.aria-valuenow]': 'mode === "determinate" ? value : null',
'[attr.mode]': 'mode',
},
inputs: ['color'],