Skip to content

Commit 9a63920

Browse files
committed
Menu: Add aria-disabled attribute to disabled items, namespace and cleanup the currentEventTarget click event
1 parent 6da7278 commit 9a63920

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ui/jquery.ui.menu.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
(function($) {
1515

1616
var idIncrement = 0,
17-
currentEventTarget;
17+
currentEventTarget = null;
1818

1919
$.widget( "ui.menu", {
2020
version: "@VERSION",
@@ -54,7 +54,9 @@ $.widget( "ui.menu", {
5454
}, this ));
5555

5656
if ( this.options.disabled ) {
57-
this.element.addClass( "ui-state-disabled" );
57+
this.element
58+
.addClass( "ui-state-disabled" )
59+
.attr( "aria-disabled", "true" );
5860
}
5961

6062
this._bind({
@@ -70,8 +72,8 @@ $.widget( "ui.menu", {
7072
var target = $( event.target );
7173
if ( target[0] != currentEventTarget ) {
7274
currentEventTarget = target[0];
73-
target.one( "click", function( event ) {
74-
currentEventTarget = "";
75+
target.one( "click.menu", function( event ) {
76+
currentEventTarget = null;
7577
});
7678
// Don't select disabled menu items
7779
if ( !target.closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
@@ -158,6 +160,9 @@ $.widget( "ui.menu", {
158160
.removeAttr( "id" )
159161
.children( ".ui-icon" )
160162
.remove();
163+
164+
// unbind currentEventTarget click event handler
165+
$( currentEventTarget ).unbind( "click.menu" );
161166
},
162167

163168
_keydown: function( event ) {
@@ -282,6 +287,9 @@ $.widget( "ui.menu", {
282287
// initialize unlinked menu-items as dividers
283288
menus.children( ":not(.ui-menu-item)" ).addClass( "ui-widget-content ui-menu-divider" );
284289

290+
// add aria-disabled attribut to any disabled menu item
291+
menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
292+
285293
submenus.each(function() {
286294
var menu = $( this ),
287295
item = menu.prev( "a" );

0 commit comments

Comments
 (0)