aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkborchers <kris.borchers@gmail.com>2012-06-01 00:03:16 -0500
committerkborchers <kris.borchers@gmail.com>2012-06-01 00:03:16 -0500
commit2da2ae5070e976c23ea4e19ff705dcba822838d8 (patch)
tree1c574d0f411e70a643e5577ef583a90fe5b881c3
parent6e7ee9860356d203e75086a1ca92864fe1d9f246 (diff)
downloadjquery-ui-2da2ae5070e976c23ea4e19ff705dcba822838d8.tar.gz
jquery-ui-2da2ae5070e976c23ea4e19ff705dcba822838d8.zip
Menu: Properly remove submenu carat icons and menu dividers during destroy and add a test for this functionality
-rw-r--r--tests/unit/menu/menu_methods.js3
-rw-r--r--ui/jquery.ui.menu.js18
2 files changed, 17 insertions, 4 deletions
diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js
index c17986816..3a7b2d8fe 100644
--- a/tests/unit/menu/menu_methods.js
+++ b/tests/unit/menu/menu_methods.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");
});
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 4bcfbfdb2..986cca168 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -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" ) );
});
},