Skip to content

Commit

Permalink
Menu: Fix unit tests and set the right menu1-activedescendant attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer committed Feb 11, 2011
1 parent 1cb1b9c commit e69839a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/unit/index.html
Expand Up @@ -46,8 +46,10 @@ <h2>Widgets</h2>
<li><a href="button/button.html">Button</a></li>
<li><a href="datepicker/datepicker.html">Datepicker</a></li>
<li><a href="dialog/dialog.html">Dialog</a></li>
<li><a href="menu/menu.html">Menu</a></li>
<li><a href="progressbar/progressbar.html">Progressbar</a></li>
<li><a href="slider/slider.html">Slider</a></li>
<li><a href="spinner/spinner.html">Spinner</a></li>
<li><a href="tabs/tabs.html">Tabs</a></li>
<li><a href="tooltip/tooltip.html">Tooltip</a></li>
</ul>
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/menu/menu_core.js
Expand Up @@ -8,13 +8,19 @@
module("menu: core");

test("accessibility", function () {
expect(3);
expect(5);
var ac = $('#menu1').menu();
var item0 = $("li:eq(0) a");

ok( ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
equals( ac.attr("role"), "listbox", "main role");
equals( ac.attr("aria-activedescendant"), "ui-active-menuitem", "aria attribute");
equals( ac.attr("aria-activedescendant"), undefined, "aria attribute not yet active");
var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
ac.menu( "activate", $.Event(), item );
equals( ac.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
var item = ac.find( "li:last" );
ac.menu( "activate", $.Event(), item );
equals( ac.attr("aria-activedescendant"), "menu1-activedescendant", "aria attribute, generated id");
});

test("items class and role", function () {
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/menu/menu_defaults.js
Expand Up @@ -3,9 +3,7 @@
*/

var menu_defaults = {
disabled: false,
navigationFilter: function() {}

disabled: false
};

commonWidgetTests('menu', { defaults: menu_defaults });
2 changes: 1 addition & 1 deletion ui/jquery.ui.menu.js
Expand Up @@ -146,7 +146,7 @@ $.widget("ui.menu", {
.end();
// need to remove the attribute before adding it for the screenreader to pick up the change
// see http://groups.google.com/group/jquery-a11y/msg/929e0c1e8c5efc8f
this.element.removeAttr("aria-activedescenant").attr("aria-activedescenant", self.itemId);
this.element.removeAttr("aria-activedescendant").attr("aria-activedescendant", self.itemId);
this._trigger( "focus", event, { item: item } );
},

Expand Down

0 comments on commit e69839a

Please sign in to comment.