]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Reset ui-menu-icons class in refresh. Fixes #9377: Menu: Refreshing should...
authorTJ VanToll <tj.vantoll@gmail.com>
Thu, 13 Jun 2013 20:47:07 +0000 (13:47 -0700)
committerScott González <scott.gonzalez@gmail.com>
Tue, 26 Nov 2013 15:53:04 +0000 (10:53 -0500)
(cherry picked from commit 91b7b9f9ab2e5baa31e37f34600457599409e161)

tests/unit/menu/menu_methods.js
ui/jquery.ui.menu.js

index c51d123c2d74f723f6ae29f6fa1e8990e7af4077..5d390c0d7c6ceb33d262f6411ba9938d1c1a5ee8 100644 (file)
@@ -69,6 +69,19 @@ test( "refresh submenu", function() {
        equal( element.find( "ul:first .ui-menu-item" ).length, 4 );
 });
 
+test( "refresh icons (see #9377)", function() {
+       expect( 3 );
+       var element = $( "#menu1" ).menu();
+       ok( !element.hasClass( "ui-menu-icons") );
+       element.find( "li:first a" ).html( '<span class="ui-icon ui-icon-disk"></span>Save</a>' );
+       element.menu( "refresh" );
+
+       ok( element.hasClass( "ui-menu-icons" ) );
+       element.find( "li:first a" ).html( "Save" );
+       element.menu( "refresh" );
+       ok( !element.hasClass( "ui-menu-icons") );
+});
+
 test( "widget", function() {
        expect( 2 );
        var element = $( "#menu1" ).menu(),
index e104065002e981a1823561ce915c9f29c2f80227..d93ef581d989fc898d34ff63d5cb6e3d91458cec 100644 (file)
@@ -282,6 +282,8 @@ $.widget( "ui.menu", {
                        icon = this.options.icons.submenu,
                        submenus = this.element.find( this.options.menus );
 
+               this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
+
                // Initialize nested menus
                submenus.filter( ":not(.ui-menu)" )
                        .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )