Skip to content

Commit d44f3d0

Browse files
committed
Menu: Use new uniqueId and removeUniqueId methods for generating id's on menus and menu items and for removing those id's during destroy. Also, properly remove the aria-disabled attribute during destroy.
1 parent 40e47c0 commit d44f3d0

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ui/jquery.ui.menu.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
*/
1414
(function($) {
1515

16-
var idIncrement = 0,
17-
currentEventTarget = null;
16+
var currentEventTarget = null;
1817

1918
$.widget( "ui.menu", {
2019
version: "@VERSION",
@@ -35,12 +34,11 @@ $.widget( "ui.menu", {
3534
},
3635
_create: function() {
3736
this.activeMenu = this.element;
38-
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
3937
this.element
38+
.uniqueId()
4039
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
4140
.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
4241
.attr({
43-
id: this.menuId,
4442
role: this.options.role,
4543
tabIndex: 0
4644
})
@@ -145,18 +143,21 @@ $.widget( "ui.menu", {
145143
.removeAttr( "aria-labelledby" )
146144
.removeAttr( "aria-expanded" )
147145
.removeAttr( "aria-hidden" )
146+
.removeAttr( "aria-disabled" )
147+
.removeUniqueId()
148148
.show();
149149

150150
// destroy menu items
151151
this.element.find( ".ui-menu-item" )
152152
.removeClass( "ui-menu-item" )
153153
.removeAttr( "role" )
154+
.removeAttr( "aria-disabled" )
154155
.children( "a" )
156+
.removeUniqueId()
155157
.removeClass( "ui-corner-all ui-state-hover" )
156158
.removeAttr( "tabIndex" )
157159
.removeAttr( "role" )
158160
.removeAttr( "aria-haspopup" )
159-
.removeAttr( "id" )
160161
// TODO: is this correct? Don't these exist in the original markup?
161162
.children( ".ui-icon" )
162163
.remove();
@@ -273,7 +274,6 @@ $.widget( "ui.menu", {
273274
refresh: function() {
274275
// initialize nested menus
275276
var menus,
276-
menuId = this.menuId,
277277
submenus = this.element.find( this.options.menus + ":not(.ui-menu)" )
278278
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
279279
.hide()
@@ -290,13 +290,11 @@ $.widget( "ui.menu", {
290290
.addClass( "ui-menu-item" )
291291
.attr( "role", "presentation" )
292292
.children( "a" )
293+
.uniqueId()
293294
.addClass( "ui-corner-all" )
294295
.attr({
295296
tabIndex: -1,
296-
role: this._itemRole(),
297-
id: function( i ) {
298-
return menuId + "-" + i;
299-
}
297+
role: this._itemRole()
300298
});
301299

302300
// initialize unlinked menu-items containing spaces and/or dashes only as dividers

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy