From 158c070e0cd860fec8d3147ce34348c354389ae0 Mon Sep 17 00:00:00 2001 From: Marcos Gil Date: Thu, 3 Oct 2019 19:15:01 +0200 Subject: [PATCH] feat(field): add aria-live attribute to feedback slot --- packages/field/src/FormControlMixin.js | 1 + packages/field/test/FormControlMixin.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/field/src/FormControlMixin.js b/packages/field/src/FormControlMixin.js index 8f30458a7..3fb099ae6 100644 --- a/packages/field/src/FormControlMixin.js +++ b/packages/field/src/FormControlMixin.js @@ -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) { diff --git a/packages/field/test/FormControlMixin.test.js b/packages/field/test/FormControlMixin.test.js index 616449832..ea280bcc3 100644 --- a/packages/field/test/FormControlMixin.test.js +++ b/packages/field/test/FormControlMixin.test.js @@ -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} +
Added to see attributes
+ + `); + + expect(lionField.$$slot('feedback').getAttribute('aria-live')).to.equal('polite'); + }); });