Skip to content

Commit

Permalink
fix(tabs): update tab plugin. Don't add aria-role if nav-tabs or nav-…
Browse files Browse the repository at this point in the history
…pills doesn't have a tabpanel associated
  • Loading branch information
Lausselloic committed Feb 17, 2017
1 parent 5a3209f commit e1b4c46
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions js/src/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,23 @@ const Tab = (($) => {
return `${prefix || 'ui-id'}-${Math.floor(Math.random() * RANDOM_NUMBER + 1)}`
}

let $tablist = $('.nav-tabs, .nav-pills')
let $lis = $tablist.children('li')
let $tabs = $tablist.find('[data-toggle="tab"], [data-toggle="pill"]')
let $tablists = $('.nav-tabs, .nav-pills')
let $tabs = $tablists.find('[data-toggle="tab"], [data-toggle="pill"]')

$tablist.attr('role', 'tablist')
$lis.attr('role', 'presentation')
$tabs.attr('role', 'tab')
$tabs.each(function () {
let tabpanel = $($(this).attr('href'))
let $tab = $(this)
let $tablist = $tab.closest('.nav-tabs, .nav-pills')
let $li = $tab.parent('li')
let tabid = $tab.attr('id') || uniqueId('ui-tab')

$tab.attr('id', tabid)
// put role tab, presentation and tablist only if there's at least one tabpanel
if(tabpanel) {
$tab.attr('role', 'tab')
$tablist.attr('role', 'tablist')
$li.attr('role', 'presentation')
}

if ($tab.hasClass('active')) {
$tab.attr({
Expand Down

0 comments on commit e1b4c46

Please sign in to comment.