From: Nicolas Coden Date: Mon, 12 Nov 2018 19:41:40 +0000 (+0100) Subject: Use pull request #11573 from ncoden/fix/dropdown-aria-missing-id-11572 for v6.5.1 X-Git-Tag: v6.5.1^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6ed54115d815f5cbdf9329e4c82b04ae200c7f3;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Use pull request #11573 from ncoden/fix/dropdown-aria-missing-id-11572 for v6.5.1 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 --- diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index 1f86313c7..d95171724 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -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();