Add tests and code for aria-hidden attributes on tabpanels
This commit is contained in:
parent
deb887727a
commit
12627f5e39
@ -48,6 +48,13 @@
|
||||
$(this).attr('role', 'tab');
|
||||
});
|
||||
|
||||
// if there isn't already a selected tab, make the first one selected
|
||||
|
||||
if($(tabList).find('[aria-selected="true"]').length == 0)
|
||||
{
|
||||
$(tabs).first().attr('aria-selected', 'true');
|
||||
}
|
||||
|
||||
$(tabPanels).each(function(index) {
|
||||
|
||||
var id = $(this).attr('id');
|
||||
@ -60,15 +67,14 @@
|
||||
$(this).attr('aria-labeledby', $(tabs[index]).attr('id'));
|
||||
$(tabs[index]).attr('aria-controls', $(this).attr('id'));
|
||||
|
||||
if($(tabs[index]).attr('aria-selected') == 'true'){
|
||||
$(this).attr('aria-hidden', 'false');
|
||||
}else{
|
||||
$(this).attr('aria-hidden', 'true');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// if there isn't already a selected tab, make the first one selected
|
||||
|
||||
if($(tabList).find('[aria-selected="true"]').length == 0)
|
||||
{
|
||||
$(tabs).first().attr('aria-selected', 'true');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$.fn[pluginName] = function ( options ) {
|
||||
|
@ -160,4 +160,25 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
test("Aria-hidden attribute generation on tabpanels", function () {
|
||||
|
||||
var tabContainer = $('#qunit-fixture #tab-container');
|
||||
var tabList = $(tabContainer).find('> ul');
|
||||
var tabPanels = $(tabContainer).children().not('ul');
|
||||
tabContainer.skeletonTabs();
|
||||
|
||||
$(tabPanels).each(function(index) {
|
||||
if(index != 0){
|
||||
equals($(this).attr('aria-hidden'),
|
||||
'true',
|
||||
'Expect tabpanel at position ' + index + ' to have aria-hidden set to true');
|
||||
}else{
|
||||
equals($(this).attr('aria-hidden'),
|
||||
'false',
|
||||
'Expect tabpanel at position ' + index + ' to have aria-hidden set to false');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user