Selectmenu: Fall back to .ui-front searching for empty jQuery objects

Fixes #9757
This commit is contained in:
Jörn Zaefferer 2014-02-21 13:35:34 +01:00
parent 8a71d0f129
commit fa99e23d18
2 changed files with 7 additions and 2 deletions

View File

@ -3,7 +3,7 @@
module( "selectmenu: options" ); module( "selectmenu: options" );
test( "appendTo another element", function () { test( "appendTo another element", function () {
expect( 8 ); expect( 9 );
var detached = $( "<div>" ), var detached = $( "<div>" ),
element = $( "#speed" ).selectmenu(); element = $( "#speed" ).selectmenu();
@ -21,6 +21,11 @@ test( "appendTo another element", function () {
element.selectmenu(); element.selectmenu();
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], $( "#selectmenu-wrap2" )[ 0 ], "null, inside .ui-front" ); equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], $( "#selectmenu-wrap2" )[ 0 ], "null, inside .ui-front" );
element.selectmenu( "destroy" ); 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" ); $( "#selectmenu-wrap2" ).removeClass( "ui-front" );
element.selectmenu().selectmenu( "option", "appendTo", "#selectmenu-wrap1" ); element.selectmenu().selectmenu( "option", "appendTo", "#selectmenu-wrap1" );

View File

@ -474,7 +474,7 @@ return $.widget( "ui.selectmenu", {
this.document.find( element ).eq( 0 ); this.document.find( element ).eq( 0 );
} }
if ( !element ) { if ( !element || !element[ 0 ] ) {
element = this.element.closest( ".ui-front" ); element = this.element.closest( ".ui-front" );
} }