feat(field): add aria-live attribute to feedback slot

This commit is contained in:
Marcos Gil 2019-10-03 19:15:01 +02:00
parent e161c711e8
commit 158c070e0c
2 changed files with 12 additions and 0 deletions

View file

@ -139,6 +139,7 @@ export const FormControlMixin = dedupeMixin(
}
}
if (_feedbackNode) {
_feedbackNode.setAttribute('aria-live', 'polite');
_feedbackNode.id = _feedbackNode.id || `feedback-${this._inputId}`;
const describeIdFeedback = ` ${_feedbackNode.id}`;
if (this._ariaDescribedby.indexOf(describeIdFeedback) === -1) {

View file

@ -62,4 +62,15 @@ describe('FormControlMixin', () => {
expect(hasDuplicate).to.be.false;
});
});
it('adds aria-live="politie" to the feedback slot', async () => {
const lionField = await fixture(html`
<${tag}>
${inputSlot}
<div slot="feedback">Added to see attributes</div>
</${tag}>
`);
expect(lionField.$$slot('feedback').getAttribute('aria-live')).to.equal('polite');
});
});