Skip to content

Commit e69839a

Browse files
committed
Menu: Fix unit tests and set the right menu1-activedescendant attribute
1 parent 1cb1b9c commit e69839a

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

tests/unit/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ <h2>Widgets</h2>
4646
<li><a href="button/button.html">Button</a></li>
4747
<li><a href="datepicker/datepicker.html">Datepicker</a></li>
4848
<li><a href="dialog/dialog.html">Dialog</a></li>
49+
<li><a href="menu/menu.html">Menu</a></li>
4950
<li><a href="progressbar/progressbar.html">Progressbar</a></li>
5051
<li><a href="slider/slider.html">Slider</a></li>
52+
<li><a href="spinner/spinner.html">Spinner</a></li>
5153
<li><a href="tabs/tabs.html">Tabs</a></li>
5254
<li><a href="tooltip/tooltip.html">Tooltip</a></li>
5355
</ul>

tests/unit/menu/menu_core.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
module("menu: core");
99

1010
test("accessibility", function () {
11-
expect(3);
11+
expect(5);
1212
var ac = $('#menu1').menu();
1313
var item0 = $("li:eq(0) a");
1414

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

2026
test("items class and role", function () {

tests/unit/menu/menu_defaults.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
*/
44

55
var menu_defaults = {
6-
disabled: false,
7-
navigationFilter: function() {}
8-
6+
disabled: false
97
};
108

119
commonWidgetTests('menu', { defaults: menu_defaults });

ui/jquery.ui.menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ $.widget("ui.menu", {
146146
.end();
147147
// need to remove the attribute before adding it for the screenreader to pick up the change
148148
// see http://groups.google.com/group/jquery-a11y/msg/929e0c1e8c5efc8f
149-
this.element.removeAttr("aria-activedescenant").attr("aria-activedescenant", self.itemId);
149+
this.element.removeAttr("aria-activedescendant").attr("aria-activedescendant", self.itemId);
150150
this._trigger( "focus", event, { item: item } );
151151
},
152152

0 commit comments

Comments
 (0)