]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Allow changing icons option after creation. Fixes #8927 - Menu: Can't change...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 27 Dec 2012 16:23:25 +0000 (17:23 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 27 Dec 2012 16:23:25 +0000 (17:23 +0100)
tests/unit/menu/menu_options.js
ui/jquery.ui.menu.js

index 2c8749e3ca3d105568c54de1840e41ac25aa6567..e3977e6ce293f37b2986fe462ae98a866b2e34c6 100644 (file)
@@ -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() {
index 7f37b6b06dcd45c1673f11601f3c435ee5626a29..8d99272d08d1eb1dd0e7cc657a7c4ef6c7107bf3 100644 (file)
@@ -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" );