fix(progress-bar): clear aria-valuenow in indeterminate or query mode (#15019)

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

Fixes #15016.
This commit is contained in:
Kristiyan Kostadinov
2019-02-22 16:06:07 +01:00
committed by Jeremy Elbourn
parent 6e52023fed
commit a88d053395
2 changed files with 45 additions and 2 deletions
+43
View File
@@ -141,6 +141,49 @@ describe('MatProgressBar', () => {
expect(rect.getAttribute('fill')).toMatch(/^url\(['"]?\/another-fake-path#.*['"]?\)$/);
});
it('should remove the `aria-valuenow` attribute in indeterminate mode', () => {
const fixture = createComponent(BasicProgressBar);
fixture.detectChanges();
const progressElement = fixture.debugElement.query(By.css('mat-progress-bar'));
const progressComponent = progressElement.componentInstance;
progressComponent.mode = 'determinate';
progressComponent.value = 50;
fixture.detectChanges();
expect(progressElement.nativeElement.getAttribute('aria-valuenow'))
.toBe('50', 'Expected aria-valuenow to be set in determinate mode.');
progressComponent.mode = 'indeterminate';
fixture.detectChanges();
expect(progressElement.nativeElement.hasAttribute('aria-valuenow'))
.toBe(false, 'Expect aria-valuenow to be cleared in indeterminate mode.');
});
it('should remove the `aria-valuenow` attribute in query mode', () => {
const fixture = createComponent(BasicProgressBar);
fixture.detectChanges();
const progressElement = fixture.debugElement.query(By.css('mat-progress-bar'));
const progressComponent = progressElement.componentInstance;
progressComponent.mode = 'determinate';
progressComponent.value = 50;
fixture.detectChanges();
expect(progressElement.nativeElement.getAttribute('aria-valuenow'))
.toBe('50', 'Expected aria-valuenow to be set in determinate mode.');
progressComponent.mode = 'query';
fixture.detectChanges();
expect(progressElement.nativeElement.hasAttribute('aria-valuenow'))
.toBe(false, 'Expect aria-valuenow to be cleared in query mode.');
});
});
describe('animation trigger on determinate setting', () => {
+2 -2
View File
@@ -90,10 +90,10 @@ let progressbarId = 0;
'role': 'progressbar',
'aria-valuemin': '0',
'aria-valuemax': '100',
'[attr.aria-valuenow]': 'value',
'[attr.aria-valuenow]': '(mode === "indeterminate" || mode === "query") ? null : value',
'[attr.mode]': 'mode',
'class': 'mat-progress-bar',
'[class._mat-animation-noopable]': `_isNoopAnimation`,
'[class._mat-animation-noopable]': '_isNoopAnimation',
},
inputs: ['color'],
templateUrl: 'progress-bar.html',