Merge pull request #301 from noventadev/feat/field-aria-live

[field] Add aria-live=polite attribute to feedback slot
This commit is contained in:
gerjanvangeest 2019-10-11 08:36:15 +02:00 committed by GitHub
commit 014751d1ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

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

View file

@ -62,4 +62,15 @@ describe('FormControlMixin', () => {
expect(hasDuplicate).to.be.false; 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');
});
}); });