diff options
| author | Max Kramer <[email protected]> | 2014-05-22 18:13:41 -0400 |
|---|---|---|
| committer | Max Kramer <[email protected]> | 2014-05-22 18:13:41 -0400 |
| commit | ee12ce83057233d271f42162ef3dd2d42d315176 (patch) | |
| tree | 4d9004c1ff822cfa0344fc1462148a07824652cd /js | |
| parent | cae7dee2361c7023bd147570509a0c40ade3c4e9 (diff) | |
| download | bootstrap-ee12ce83057233d271f42162ef3dd2d42d315176.tar.xz bootstrap-ee12ce83057233d271f42162ef3dd2d42d315176.zip | |
Add aria-haspopup and aria-expanded attributes to dropdown plugin
1. Add aria-haspopup="true" and aria-expanded="false" to dropdown docs
2. Toggle aria-expanded between "true" and "false" when opening and closing dropdown
Satisfy item 1 from https://github.com/paypal/bootstrap-accessibility-plugin#dropdown. See #13553.
Diffstat (limited to 'js')
| -rw-r--r-- | js/dropdown.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/js/dropdown.js b/js/dropdown.js index bc671fef0..1924f70ae 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -42,7 +42,9 @@ if (e.isDefaultPrevented()) return - $this.trigger('focus') + $this + .trigger('focus') + .attr('aria-expanded', 'true') $parent .toggleClass('open') @@ -88,11 +90,13 @@ if (e && e.which === 3) return $(backdrop).remove() $(toggle).each(function () { - var $parent = getParent($(this)) + var $this = $(this) + var $parent = getParent($this) var relatedTarget = { relatedTarget: this } if (!$parent.hasClass('open')) return $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) if (e.isDefaultPrevented()) return + $this.attr('aria-expanded', 'false') $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget) }) } |
