From 2bfd3e0c483e0d26673ccf6dcbaf5734c749ba07 Mon Sep 17 00:00:00 2001 From: Stefan Lisper Date: Thu, 12 Apr 2018 11:59:28 +0200 Subject: [PATCH] fixed bug where aria-controls is not updated with multiple ids --- js/foundation.toggler.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/foundation.toggler.js b/js/foundation.toggler.js index f3ec60f10..effaa7fcc 100644 --- a/js/foundation.toggler.js +++ b/js/foundation.toggler.js @@ -65,6 +65,21 @@ class Toggler extends Plugin { 'aria-controls': id, 'aria-expanded': this.$element.is(':hidden') ? false : true }); + + // Add ARIA attributes to triggers + var id = this.$element[0].id, + $triggers = $(`[data-open~="${id}"], [data-close~="${id}"], [data-toggle~="${id}"]`), + that = this; + + $triggers.each(function(index, element) { + var $this = $(element); + + //make sure not to duplicate id in aria-controls + $this.attr({ + 'aria-controls': `${$this.attr('aria-controls') ? $this.attr('aria-controls').replace(id, '') : ''} ${id}`.trim(), + 'aria-expanded': that.$element.is(':hidden') ? false : true + }); + }); } /** -- 2.47.2