mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Fall back to .ui-front searching for empty jQuery objects
Fixes #9755
This commit is contained in:
parent
0bb807bb42
commit
2ef1b16e4d
@ -5,13 +5,18 @@ module( "autocomplete: options" );
|
||||
var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby",
|
||||
"python", "c", "scala", "groovy", "haskell", "perl" ];
|
||||
|
||||
test( "appendTo", function() {
|
||||
expect( 8 );
|
||||
var detached = $( "<div>" ),
|
||||
element = $( "#autocomplete" ).autocomplete();
|
||||
test( "appendTo: null", function() {
|
||||
expect( 1 );
|
||||
var element = $( "#autocomplete" ).autocomplete();
|
||||
equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body,
|
||||
"defaults to body" );
|
||||
element.autocomplete( "destroy" );
|
||||
});
|
||||
|
||||
test( "appendTo: explicit", function() {
|
||||
expect( 6 );
|
||||
var detached = $( "<div>" ),
|
||||
element = $( "#autocomplete" );
|
||||
|
||||
element.autocomplete({
|
||||
appendTo: ".autocomplete-wrap"
|
||||
@ -22,13 +27,6 @@ test( "appendTo", function() {
|
||||
"only appends to one element" );
|
||||
element.autocomplete( "destroy" );
|
||||
|
||||
$( "#autocomplete-wrap2" ).addClass( "ui-front" );
|
||||
element.autocomplete();
|
||||
equal( element.autocomplete( "widget" ).parent()[ 0 ],
|
||||
$( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" );
|
||||
element.autocomplete( "destroy" );
|
||||
$( "#autocomlete-wrap2" ).removeClass( "ui-front" );
|
||||
|
||||
element.autocomplete().autocomplete( "option", "appendTo", "#autocomplete-wrap1" );
|
||||
equal( element.autocomplete( "widget" ).parent()[ 0 ],
|
||||
$( "#autocomplete-wrap1" )[ 0 ], "modified after init" );
|
||||
@ -54,6 +52,23 @@ test( "appendTo", function() {
|
||||
element.autocomplete( "destroy" );
|
||||
});
|
||||
|
||||
test( "appendTo: ui-front", function() {
|
||||
expect( 2 );
|
||||
var element = $( "#autocomplete" );
|
||||
|
||||
$( "#autocomplete-wrap2" ).addClass( "ui-front" );
|
||||
element.autocomplete();
|
||||
equal( element.autocomplete( "widget" ).parent()[ 0 ],
|
||||
$( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" );
|
||||
element.autocomplete( "destroy" );
|
||||
|
||||
element.autocomplete({
|
||||
appendTo: $()
|
||||
});
|
||||
equal( element.autocomplete( "widget" ).parent()[ 0 ],
|
||||
$( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" );
|
||||
});
|
||||
|
||||
function autoFocusTest( afValue, focusedLength ) {
|
||||
var element = $( "#autocomplete" ).autocomplete({
|
||||
autoFocus: afValue,
|
||||
|
2
ui/jquery.ui.autocomplete.js
vendored
2
ui/jquery.ui.autocomplete.js
vendored
@ -339,7 +339,7 @@ $.widget( "ui.autocomplete", {
|
||||
this.document.find( element ).eq( 0 );
|
||||
}
|
||||
|
||||
if ( !element ) {
|
||||
if ( !element || !element[ 0 ] ) {
|
||||
element = this.element.closest( ".ui-front" );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user