diff --git a/tests/unit/selectmenu/selectmenu_options.js b/tests/unit/selectmenu/selectmenu_options.js index 1ab098a75..28b55888c 100644 --- a/tests/unit/selectmenu/selectmenu_options.js +++ b/tests/unit/selectmenu/selectmenu_options.js @@ -3,7 +3,7 @@ module( "selectmenu: options" ); test( "appendTo another element", function () { - expect( 8 ); + expect( 9 ); var detached = $( "
" ), element = $( "#speed" ).selectmenu(); @@ -21,6 +21,11 @@ test( "appendTo another element", function () { element.selectmenu(); equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], $( "#selectmenu-wrap2" )[ 0 ], "null, inside .ui-front" ); element.selectmenu( "destroy" ); + + element.selectmenu({ + appendTo: $() + }); + equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], $( "#selectmenu-wrap2" )[ 0 ], "empty jQuery object, inside .ui-front" ); $( "#selectmenu-wrap2" ).removeClass( "ui-front" ); element.selectmenu().selectmenu( "option", "appendTo", "#selectmenu-wrap1" ); diff --git a/ui/selectmenu.js b/ui/selectmenu.js index 1c1cd07dc..66398a6e3 100644 --- a/ui/selectmenu.js +++ b/ui/selectmenu.js @@ -474,7 +474,7 @@ return $.widget( "ui.selectmenu", { this.document.find( element ).eq( 0 ); } - if ( !element ) { + if ( !element || !element[ 0 ] ) { element = this.element.closest( ".ui-front" ); }