]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fixed bug where aria-controls is not updated with multiple ids
authorStefan Lisper <Stefan.Lisper@knowit.se>
Thu, 12 Apr 2018 09:59:28 +0000 (11:59 +0200)
committerStefan Lisper <Stefan.Lisper@knowit.se>
Thu, 12 Apr 2018 09:59:28 +0000 (11:59 +0200)
js/foundation.toggler.js

index f3ec60f109abfa8cb684734a60303353844da867..effaa7fcc5f0648a38b9bd6157b9a69db0d14810 100644 (file)
@@ -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
+      });
+    });
   }
 
   /**