Skip to content

Commit

Permalink
Selectmenu: Copy title attributes
Browse files Browse the repository at this point in the history
Fixes #10435
Closes gh-1298
  • Loading branch information
fnagel authored and scottgonzalez committed Nov 4, 2014
1 parent 809cc0f commit 9793739
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
24 changes: 16 additions & 8 deletions tests/unit/selectmenu/selectmenu_core.js
Expand Up @@ -3,15 +3,21 @@
module( "selectmenu: core" );

asyncTest( "accessibility", function() {
var wrappers,
element = $( "#speed" ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" );
var wrappers, button, menu,
element = $( "#speed" ).attr( "title", "A demo title" );

element.find( "option" ).each(function( index ) {
$( this ).attr( "title", "A demo title #" + index );
});

element.selectmenu();
button = element.selectmenu( "widget" );
menu = element.selectmenu( "menuWidget" );

button.simulate( "focus" );
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );

expect( 12 + wrappers.length * 2 );
expect( 13 + wrappers.length * 3 );

setTimeout(function() {
equal( button.attr( "role" ), "combobox", "button role" );
Expand All @@ -25,6 +31,7 @@ asyncTest( "accessibility", function() {
"button link aria-labelledby"
);
equal( button.attr( "tabindex" ), 0, "button link tabindex" );
equal( button.attr( "title" ), "A demo title", "button title" );

equal( menu.attr( "role" ), "listbox", "menu role" );
equal( menu.attr( "aria-labelledby" ), button.attr( "id" ), "menu aria-labelledby" );
Expand All @@ -36,9 +43,10 @@ asyncTest( "accessibility", function() {
"menu aria-activedescendant"
);
$.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" );
var item = $( this );
equal( item.attr( "role" ), "option", "menu item #" + index +" role" );
equal( item.attr( "tabindex" ), -1, "menu item #" + index +" tabindex" );
equal( item.attr( "title" ), "A demo title #" + index, "menu item #" + index + " title" );
});
start();
});
Expand Down
7 changes: 5 additions & 2 deletions ui/selectmenu.js
Expand Up @@ -94,7 +94,8 @@ return $.widget( "ui.selectmenu", {
"aria-expanded": "false",
"aria-autocomplete": "list",
"aria-owns": this.ids.menu,
"aria-haspopup": "true"
"aria-haspopup": "true",
title: this.element.attr( "title" )
})
.insertAfter( this.element );

Expand Down Expand Up @@ -317,7 +318,9 @@ return $.widget( "ui.selectmenu", {

_renderItem: function( ul, item ) {
var li = $( "<li>" ),
wrapper = $( "<div>" );
wrapper = $( "<div>", {
title: item.element.attr( "title" )
});

if ( item.disabled ) {
li.addClass( "ui-state-disabled" );
Expand Down

0 comments on commit 9793739

Please sign in to comment.