14
14
( function ( $ ) {
15
15
16
16
var idIncrement = 0 ,
17
- currentEventTarget ;
17
+ currentEventTarget = null ;
18
18
19
19
$ . widget ( "ui.menu" , {
20
20
version : "@VERSION" ,
@@ -54,7 +54,9 @@ $.widget( "ui.menu", {
54
54
} , this ) ) ;
55
55
56
56
if ( this . options . disabled ) {
57
- this . element . addClass ( "ui-state-disabled" ) ;
57
+ this . element
58
+ . addClass ( "ui-state-disabled" )
59
+ . attr ( "aria-disabled" , "true" ) ;
58
60
}
59
61
60
62
this . _bind ( {
@@ -70,8 +72,8 @@ $.widget( "ui.menu", {
70
72
var target = $ ( event . target ) ;
71
73
if ( target [ 0 ] != currentEventTarget ) {
72
74
currentEventTarget = target [ 0 ] ;
73
- target . one ( "click" , function ( event ) {
74
- currentEventTarget = "" ;
75
+ target . one ( "click.menu " , function ( event ) {
76
+ currentEventTarget = null ;
75
77
} ) ;
76
78
// Don't select disabled menu items
77
79
if ( ! target . closest ( ".ui-menu-item" ) . is ( ".ui-state-disabled" ) ) {
@@ -158,6 +160,9 @@ $.widget( "ui.menu", {
158
160
. removeAttr ( "id" )
159
161
. children ( ".ui-icon" )
160
162
. remove ( ) ;
163
+
164
+ // unbind currentEventTarget click event handler
165
+ $ ( currentEventTarget ) . unbind ( "click.menu" ) ;
161
166
} ,
162
167
163
168
_keydown : function ( event ) {
@@ -282,6 +287,9 @@ $.widget( "ui.menu", {
282
287
// initialize unlinked menu-items as dividers
283
288
menus . children ( ":not(.ui-menu-item)" ) . addClass ( "ui-widget-content ui-menu-divider" ) ;
284
289
290
+ // add aria-disabled attribut to any disabled menu item
291
+ menus . children ( ".ui-state-disabled" ) . attr ( "aria-disabled" , "true" ) ;
292
+
285
293
submenus . each ( function ( ) {
286
294
var menu = $ ( this ) ,
287
295
item = menu . prev ( "a" ) ;
0 commit comments