From ff11b69a67e0176c851ff3bdec997c7a75d47a42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 21 Mar 2013 15:54:50 -0400 Subject: [PATCH] Autocomplete: Insert the live region before the input. Fixes #9172 - Autocomplete: .replaceWith() fails to replace. --- tests/unit/autocomplete/autocomplete_core.js | 10 ++++++++++ ui/jquery.ui.autocomplete.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index a9fc1143c..6f1195910 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -188,4 +188,14 @@ test( "ARIA", function() { "Live region for multiple values" ); }); +test( ".replaceWith() (#9172)", function() { + expect( 1 ); + + var element = $( "#autocomplete" ).autocomplete(), + replacement = "
test
", + parent = element.parent(); + element.replaceWith( replacement ); + equal( parent.html(), replacement ); +}); + }( jQuery ) ); diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 3d0343379..28cfdf2fb 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -296,7 +296,7 @@ $.widget( "ui.autocomplete", { "aria-live": "polite" }) .addClass( "ui-helper-hidden-accessible" ) - .insertAfter( this.element ); + .insertBefore( this.element ); // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete -- 2.39.5