Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Menu: Allow changing icons option after creation. Fixes #8927 - Menu:…

… Can't change icons option after init
  • Loading branch information...
commit 2c3d311f90281e95827708e2e8d0e52832a437de 1 parent 0d53fbf
@jzaefferer jzaefferer authored
Showing with 13 additions and 1 deletion.
  1. +4 −1 tests/unit/menu/menu_options.js
  2. +9 −0 ui/jquery.ui.menu.js
View
5 tests/unit/menu/menu_options.js
@@ -41,9 +41,12 @@ test( "{ disabled: false }", function() {
});
test( "{ icons: default }", function() {
- expect( 1 );
+ expect( 2 );
var element = $( "#menu2" ).menu();
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" );
+
+ element.menu("option", "icons.submenu", "ui-icon-triangle-1-e");
+ equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-triangle-1-e" );
});
test( "{ icons: { submenu: 'custom' } }", function() {
View
9 ui/jquery.ui.menu.js
@@ -343,6 +343,15 @@ $.widget( "ui.menu", {
}[ this.options.role ];
},
+ _setOption: function( key, value ) {
+ if ( key === "icons" ) {
+ this.element.find( ".ui-menu-icon" )
+ .removeClass( this.options.icons.submenu )
+ .addClass( value.submenu );
+ }
+ this._super( key, value );
+ },
+
focus: function( event, item ) {
var nested, focused;
this.blur( event, event && event.type === "focus" );
Please sign in to comment.
Something went wrong with that request. Please try again.