module( "selectmenu: core" );
asyncTest( "accessibility", function() {
- var links,
+ var wrappers,
element = $( "#speed" ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" );
button.simulate( "focus" );
- links = menu.find( "li.ui-menu-item" );
+ wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
- expect( 12 + links.length * 2 );
+ expect( 12 + wrappers.length * 2 );
setTimeout(function() {
equal( button.attr( "role" ), "combobox", "button role" );
equal( button.attr( "aria-owns" ), menu.attr( "id" ), "button aria-owns" );
equal(
button.attr( "aria-labelledby" ),
- links.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"button link aria-labelledby"
);
equal( button.attr( "tabindex" ), 0, "button link tabindex" );
equal( menu.attr( "tabindex" ), 0, "menu tabindex" );
equal(
menu.attr( "aria-activedescendant" ),
- links.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"menu aria-activedescendant"
);
- $.each( links, function( index ) {
+ $.each( wrappers, function( index ) {
var link = $( this );
equal( link.attr( "role" ), "option", "menu link #" + index +" role" );
equal( link.attr( "tabindex" ), -1, "menu link #" + index +" tabindex" );
asyncTest( "state synchronization - after keydown on button - " + settings.type, function() {
expect( 4 );
- var links,
+ var wrappers,
element = $( settings.selector ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" ),
button.simulate( "focus" );
setTimeout(function() {
- links = menu.find( "li.ui-menu-item" );
+ wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal(
menu.attr( "aria-activedescendant" ),
- links.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"menu aria-activedescendant"
);
equal(
button.attr( "aria-activedescendant" ),
- links.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"button aria-activedescendant"
);
equal(
asyncTest( "state synchronization - after click on item - " + settings.type, function() {
expect( 4 );
- var links,
+ var wrappers,
element = $( settings.selector ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" ),
button.simulate( "focus" );
setTimeout(function() {
- links = menu.find( "li.ui-menu-item" );
+ wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
menu.find( "li" ).last().simulate( "mouseover" ).trigger( "click" );
equal(
menu.attr( "aria-activedescendant" ),
- links.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"menu aria-activedescendant"
);
equal(
button.attr( "aria-activedescendant" ),
- links.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"button aria-activedescendant"
);
equal(
"after focus item and keydown on button - " + settings.type, function() {
expect( 4 );
- var links,
+ var wrappers,
element = $( settings.selector ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" ),
button.simulate( "focus" );
setTimeout(function() {
- links = menu.find( "li.ui-menu-item" );
+ wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
// Open menu and click first item
button.trigger( "click" );
- links.first().simulate( "mouseover" ).trigger( "click" );
+ wrappers.first().simulate( "mouseover" ).trigger( "click" );
// Open menu again and hover item
button.trigger( "click" );
- links.eq( 3 ).simulate( "mouseover" );
+ wrappers.eq( 3 ).simulate( "mouseover" );
// Close and use keyboard control on button
button.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
setTimeout(function() {
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal( menu.attr( "aria-activedescendant" ), links.eq( 1 ).attr( "id" ),
+ equal( menu.attr( "aria-activedescendant" ), wrappers.eq( 1 ).attr( "id" ),
"menu aria-activedescendant" );
- equal( button.attr( "aria-activedescendant" ), links.eq( 1 ).attr( "id" ),
+ equal( button.attr( "aria-activedescendant" ), wrappers.eq( 1 ).attr( "id" ),
"button aria-activedescendant" );
equal( element.find( "option:selected" ).val(), options.eq( 1 ).val() ,
"original select state" );
asyncTest( "item looping - " + settings.type, function() {
expect( 4 );
- var links,
+ var wrappers,
element = $( settings.selector ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" );
button.simulate( "focus" );
setTimeout(function() {
- links = menu.find( "li.ui-menu-item" );
+ wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
- links.first().simulate( "mouseover" ).trigger( "click" );
+ wrappers.first().simulate( "mouseover" ).trigger( "click" );
equal( element[ 0 ].selectedIndex, 0, "First item is selected" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( element[ 0 ].selectedIndex, 0, "No looping beyond first item" );
button.trigger( "click" );
- links.last().simulate( "mouseover" ).trigger( "click" );
- equal( element[ 0 ].selectedIndex, links.length - 1, "Last item is selected" );
+ wrappers.last().simulate( "mouseover" ).trigger( "click" );
+ equal( element[ 0 ].selectedIndex, wrappers.length - 1, "Last item is selected" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal( element[ 0 ].selectedIndex, links.length - 1, "No looping behind last item" );
+ equal( element[ 0 ].selectedIndex, wrappers.length - 1, "No looping behind last item" );
start();
});
});
asyncTest( "item focus and active state - " + settings.type, function() {
expect( 4 );
- var items, focusedItem,
+ var wrappers, focusedItem,
element = $( settings.selector ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" );
button.simulate( "focus" );
setTimeout(function() {
- items = menu.find( "li.ui-menu-item" );
+ wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
setTimeout(function() {
checkItemClasses();
- items.eq( 3 ).simulate( "mouseover" ).trigger( "click" );
+ wrappers.eq( 3 ).simulate( "mouseover" ).trigger( "click" );
button.trigger( "click" );
- items.eq( 2 ).simulate( "mouseover" );
+ wrappers.eq( 2 ).simulate( "mouseover" );
$( document ).trigger( "click" );
button.trigger( "click" );
- items.eq( 1 ).simulate( "mouseover" );
+ wrappers.eq( 1 ).simulate( "mouseover" );
$( document ).trigger( "click" );
button.trigger( "click" );
});
function checkItemClasses() {
- focusedItem = menu.find( "li.ui-state-focus" );
+ focusedItem = menu.find( "li .ui-state-focus" );
equal( focusedItem.length, 1, "only one item has ui-state-focus class" );
- equal( focusedItem.attr( "id" ), items.eq( element[ 0 ].selectedIndex ).attr( "id" ),
+ equal( focusedItem.attr( "id" ), wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"selected item has ui-state-focus class" );
}
});
asyncTest( "empty option - " + settings.type, function() {
expect( 7 );
- var button, menu, links, link,
+ var button, menu, wrappers, wrapper,
element = $( settings.selector );
element.find( "option" ).first().text( "" );
button.simulate( "focus" );
setTimeout(function() {
- links = menu.find( "li:not(.ui-selectmenu-optgroup)" );
- link = links.first();
+ wrappers = menu.find( "li:not(.ui-selectmenu-optgroup) .ui-menu-item-wrapper" );
+ wrapper = wrappers.first();
button.trigger( "click" );
- equal( links.length, element.find( "option" ).length,
+ equal( wrappers.length, element.find( "option" ).length,
"correct amount of list elements" );
- ok( link.outerHeight() > 10, "empty item seems to have reasonable height" );
- ok( link.attr( "id" ), "empty item has id attribute" );
- ok( link.hasClass( "ui-menu-item" ), "empty item has ui-menu-item class" );
- ok( !link.hasClass( "ui-menu-divider" ),
+ ok( wrapper.outerHeight() > 10, "empty item seems to have reasonable height" );
+ ok( wrapper.attr( "id" ), "empty item has id attribute" );
+ ok( wrapper.parent().hasClass( "ui-menu-item" ),
+ "empty item has ui-menu-item class" );
+ ok( !wrapper.hasClass( "ui-menu-divider" ),
"empty item does not have ui-menu-divider class" );
- equal( link.attr( "tabindex" ), -1, "empty item has tabindex" );
- equal( link.attr( "role" ), "option", "empty item has role option" );
+ equal( wrapper.attr( "tabindex" ), -1, "empty item has tabindex" );
+ equal( wrapper.attr( "role" ), "option", "empty item has role option" );
start();
});