aboutsummaryrefslogtreecommitdiff
path: root/js/tab.js
diff options
context:
space:
mode:
authorCameron Little <[email protected]>2014-09-09 18:17:56 +0200
committerHeinrich Fenkart <[email protected]>2014-10-26 02:25:47 +0100
commit0755d529c6ded76a6c04b13b36ce0471e4bb1ee8 (patch)
tree5cb76c53a93231b85e68bb62bdfa9e3bcdf292b8 /js/tab.js
parent38217ee405de65a3fd3e2c217f8d5be8563da327 (diff)
downloadbootstrap-0755d529c6ded76a6c04b13b36ce0471e4bb1ee8.tar.xz
bootstrap-0755d529c6ded76a6c04b13b36ce0471e4bb1ee8.zip
Tabs plugin accessibility
Added support for `aria-expanded` toggling via JavaScript. Added `aria-controls`, `aria-expanded`, `aria-labelledby` to tabs docs. Added `aria-expanded` unit test for the tabs plugin. See also #13554. Closes #14154 by merging it.
Diffstat (limited to 'js/tab.js')
-rw-r--r--js/tab.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/js/tab.js b/js/tab.js
index c597d7ab6..dd307a424 100644
--- a/js/tab.js
+++ b/js/tab.js
@@ -71,9 +71,15 @@
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
- .removeClass('active')
+ .removeClass('active')
+ .end()
+ .find('[data-toggle="tab"]')
+ .attr('aria-expanded', false)
- element.addClass('active')
+ element
+ .addClass('active')
+ .find('[data-toggle="tab"]')
+ .attr('aria-expanded', true)
if (transition) {
element[0].offsetWidth // reflow for transition
@@ -83,7 +89,12 @@
}
if (element.parent('.dropdown-menu')) {
- element.closest('li.dropdown').addClass('active')
+ element
+ .closest('li.dropdown')
+ .addClass('active')
+ .end()
+ .find('[data-toggle="tab"]')
+ .attr('aria-expanded', true)
}
callback && callback()