From: Rhys Lloyd Date: Mon, 18 Feb 2019 04:10:20 +0000 (+1030) Subject: fix(accordion): adds role="presentation" to accordion items #11659 X-Git-Tag: v6.6.0~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bc6d728dc9f03ae7f6f608990922bb69299b62b;p=thirdparty%2Ffoundation%2Ffoundation-sites.git 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 --- 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) {