1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-16 10:34:07 +02:00

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.
This commit is contained in:
Max Kramer
2014-05-22 18:13:41 -04:00
parent cae7dee236
commit ee12ce8305
2 changed files with 14 additions and 10 deletions

View File

@@ -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)
})
}