Autocomplete: Append liveRegion to body to support detached init. Fixes #9590 - Dynamically adding input field breaks auto-complete's accessibility for screen readers

This commit is contained in:
Jörn Zaefferer 2013-10-18 15:39:20 +02:00
parent b99f8258bf
commit 7b9c810b9a
2 changed files with 10 additions and 1 deletions

View File

@ -257,6 +257,15 @@ test( "ARIA", function() {
"Live region for multiple values" );
});
test( "ARIA, init on detached input", function() {
expect( 1 );
var element = $( "<input>" ).autocomplete({
source: [ "java", "javascript" ]
}),
liveRegion = element.autocomplete( "instance" ).liveRegion;
equal( liveRegion.parent().length, 1, "liveRegion must have a parent" );
});
test( ".replaceWith() (#9172)", function() {
expect( 1 );

View File

@ -294,7 +294,7 @@ $.widget( "ui.autocomplete", {
"aria-live": "polite"
})
.addClass( "ui-helper-hidden-accessible" )
.insertBefore( this.element );
.appendTo( this.document[ 0 ].body );
// turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete