diff options
| author | Mark Otto <[email protected]> | 2014-10-25 18:28:07 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2014-10-25 18:28:07 -0700 |
| commit | 75620dadcc3e6f6372f8e53a8f91e31746c87c25 (patch) | |
| tree | dd0148de0c72c636d288705d0a5bfa391ca744c6 /js | |
| parent | 41a26ced249e5d4546823c2adf7f95f15005ecbf (diff) | |
| parent | 0755d529c6ded76a6c04b13b36ce0471e4bb1ee8 (diff) | |
| download | bootstrap-75620dadcc3e6f6372f8e53a8f91e31746c87c25.tar.xz bootstrap-75620dadcc3e6f6372f8e53a8f91e31746c87c25.zip | |
Merge branch 'master' of github.com:twbs/bootstrap
Diffstat (limited to 'js')
| -rw-r--r-- | js/tab.js | 17 | ||||
| -rw-r--r-- | js/tests/unit/tab.js | 24 |
2 files changed, 38 insertions, 3 deletions
@@ -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() diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index 6fbf36c50..9b2a18d57 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -178,4 +178,28 @@ $(function () { .bootstrapTab('show') }) + test('selected tab should have aria-expanded', function () { + var tabsHTML = '<ul class="nav nav-tabs">' + + '<li class="active"><a href="#home" toggle="tab" aria-expanded="true">Home</a></li>' + + '<li><a href="#profile" toggle="tab" aria-expanded="false">Profile</a></li>' + + '</ul>' + var $tabs = $(tabsHTML).appendTo('#qunit-fixture') + + $tabs.find('li:first a').bootstrapTab('show') + equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true') + equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'hidden tab has aria-expanded = false') + + $tabs.find('li:last a').click() + equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'after click, shown tab has aria-expanded = true') + equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after click, hidden tab has aria-expanded = false') + + $tabs.find('li:first a').bootstrapTab('show') + equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true') + equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'hidden tab has aria-expanded = false') + + $tabs.find('li:first a').click() + equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'after second show event, shown tab still has aria-expanded = true') + equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after second show event, hidden tab has aria-expanded = false') + }) + }) |
