Skip to content
Permalink
Browse files

Menu: Properly remove submenu carat icons and menu dividers during de…

…stroy and add a test for this functionality
  • Loading branch information...
kborchers committed Jun 1, 2012
1 parent 6e7ee98 commit 2da2ae5070e976c23ea4e19ff705dcba822838d8
Showing with 17 additions and 4 deletions.
  1. +3 −0 tests/unit/menu/menu_methods.js
  2. +14 −4 ui/jquery.ui.menu.js
@@ -46,6 +46,9 @@ test("destroy", function() {
domEqual("#menu1", function() {
$("#menu1").menu().menu("destroy");
});
domEqual("#menu2", function() {
$("#menu2").menu().menu("destroy");
});
domEqual("#menu5", function() {
$("#menu5").menu().menu("destroy");
});
@@ -137,7 +137,7 @@ $.widget( "ui.menu", {
this.element
.removeAttr( "aria-activedescendant" )
.find( ".ui-menu" ).andSelf()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
.removeAttr( "role" )
.removeAttr( "tabIndex" )
.removeAttr( "aria-labelledby" )
@@ -157,7 +157,16 @@ $.widget( "ui.menu", {
.removeClass( "ui-corner-all ui-state-hover" )
.removeAttr( "tabIndex" )
.removeAttr( "role" )
.removeAttr( "aria-haspopup" );
.removeAttr( "aria-haspopup" )
.children().each( function() {
var elem = $( this );
if ( elem.data( "ui-menu-submenu-carat" ) ) {
elem.remove();
}
});

// destroy menu dividers
this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );

// unbind currentEventTarget click event handler
$( currentEventTarget ).unbind( "click.menu" );
@@ -309,11 +318,12 @@ $.widget( "ui.menu", {

submenus.each(function() {
var menu = $( this ),
item = menu.prev( "a" );
item = menu.prev( "a" ),
submenuCarat = $( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' ).data( "ui-menu-submenu-carat", true );

item
.attr( "aria-haspopup", "true" )
.prepend( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' );
.prepend( submenuCarat );
menu.attr( "aria-labelledby", item.attr( "id" ) );
});
},

1 comment on commit 2da2ae5

@jzaefferer

This comment has been minimized.

Copy link
Member

commented on 2da2ae5 Dec 27, 2012

Why did you set the data attribute, instead of just finding .ui-menu-icon elements and removing those? We aren't using that class anywhere else.

Please sign in to comment.
You can’t perform that action at this time.