From: kborchers Date: Fri, 25 May 2012 04:44:51 +0000 (-0500) Subject: Menu: Better handling of divider elements and menu items without anchors. X-Git-Tag: 1.9.0-beta.1~102 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fe7ca1f1c3922a301169256ed0614c5529e40454;p=jquery-ui.git Menu: Better handling of divider elements and menu items without anchors. --- diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index 62585d863..a8a76bf14 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -88,8 +88,11 @@ Delphi
  • Perch
  • diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index ec3e7d3c4..2132ff764 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -315,16 +315,27 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus", equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)"); log("keydown",true); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - setTimeout( menukeyboard5, 50 ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + setTimeout( function() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + setTimeout( function() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal( $("#log").html(), "0,4,2,0,1,0,6,5,keydown,", "Keydown skip dividers and items without anchors"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + setTimeout( menukeyboard6, 50 ); + }, 50 ); + }, 50 ); } - function menukeyboard5() { - equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)"); - - log("keydown",true); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - equal( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)"); + function menukeyboard6() { + equal( $("#log").html(), "Ada,keydown,", "Keydown ENTER (open submenu)"); start(); } diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index fc4fce4f1..c17986816 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -29,13 +29,17 @@ test( "enable/disable", function() { }); test( "refresh", function() { - expect( 3 ); + expect( 5 ); var menu = $( "#menu1" ).menu(); equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); menu.append("
  • test item
  • ").menu("refresh"); equal(menu.find(".ui-menu-item").length,6,"Incorrect number of menu items"); menu.find(".ui-menu-item:last").remove().end().menu("refresh"); equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); + menu.append("
  • ---
  • ").menu("refresh"); + equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); + menu.children(":last").remove().end().menu("refresh"); + equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); }); test("destroy", function() { diff --git a/tests/visual/menu/menu.html b/tests/visual/menu/menu.html index f92de61db..dd86a6e4b 100644 --- a/tests/visual/menu/menu.html +++ b/tests/visual/menu/menu.html @@ -15,7 +15,7 @@ $( "

    " ).text( "Selected: " + ui.item.text() ).appendTo( "#log" ); } - $( "#menu1, #menu2, #menu3, .menu4" ).menu({ + $( "#menu1, #menu2, #menu3, .menu4, #menu7" ).menu({ select: logger }); @@ -58,7 +58,6 @@

  • Ada
  • Adamsville
  • Addyston
  • -
  • Delphi