From 3bc6d728dc9f03ae7f6f608990922bb69299b62b Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Mon, 18 Feb 2019 14:40:20 +1030 Subject: [PATCH] fix(accordion): adds role="presentation" to accordion items #11659 Adds `role="presentation"` to accordion items to comply with WAI. Includes the respective unit test. fix #11659 --- js/foundation.accordion.js | 2 ++ test/javascript/components/accordion.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index d2e42f916..e2f9116f0 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -44,6 +44,8 @@ class Accordion extends Plugin { this.$element.attr('role', 'tablist'); this.$tabs = this.$element.children('[data-accordion-item]'); + + this.$tabs.attr({'role': 'presentation'}); this.$tabs.each(function(idx, el) { var $el = $(el), diff --git a/test/javascript/components/accordion.js b/test/javascript/components/accordion.js index 362a8fef1..315847062 100644 --- a/test/javascript/components/accordion.js +++ b/test/javascript/components/accordion.js @@ -39,6 +39,13 @@ describe('Accordion', function() { plugin.$element.should.be.an('object'); plugin.options.should.be.an('object'); }); + + it('applies role="presentation" to the list item to conform with WAI', function () { + $html = $(template).appendTo('body'); + plugin = new Foundation.Accordion($html, {allowAllClosed: true}); + + $html.find('.accordion-item').eq(0).should.have.attr('role', 'presentation'); + }); }); describe('up()', function(done) { -- 2.47.2