]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11573 from ncoden/fix/dropdown-aria-missing-id-11572 for v6.5.1
authorNicolas Coden <nicolas@ncoden.fr>
Mon, 12 Nov 2018 19:41:40 +0000 (20:41 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Mon, 12 Nov 2018 20:44:42 +0000 (21:44 +0100)
5ddb04b6e fix: ensure Dropdown aria-labelledby to have an ID #11572
adce39107 fix: revert inadvertent substitution of Dropdown "aria-labelledby" attribute

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
js/foundation.dropdown.js

index 1f86313c73fc83577c3290ecc057ee08e1872669..d951717240e15808fc8fa60b4310b5a8ef885198 100644 (file)
@@ -66,16 +66,20 @@ class Dropdown extends Positionable {
       this.$parent = null;
     }
 
-    // Do not change the `labelledby` if it is defined
-    var labelledby = this.$element.attr('aria-labelledby')
-      || this.$currentAnchor.attr('id')
-      || GetYoDigits(6, 'dd-anchor');
+    // Set [aria-labelledby] on the Dropdown if it is not set
+    if (typeof this.$element.attr('aria-labelledby') === 'undefined') {
+      // Get the anchor ID or create one
+      if (typeof this.$currentAnchor.attr('id') === 'undefined') {
+        this.$currentAnchor.attr('id', GetYoDigits(6, 'dd-anchor'));
+      };
+
+      this.$element.attr('aria-labelledby', this.$currentAnchor.attr('id'));
+    }
 
     this.$element.attr({
       'aria-hidden': 'true',
       'data-yeti-box': $id,
       'data-resize': $id,
-      'aria-labelledby': labelledby
     });
 
     super._init();