Skip to main content

Bug Tracker

Side navigation

#2844 closed bug (invalid)

Opened May 12, 2008 09:44AM UTC

Closed October 13, 2009 12:09AM UTC

Last modified March 14, 2012 09:41PM UTC

Autocomplete plugin uses innerHTML and causes troubles on XHTML pages

Reported by: Messere Owned by: joern
Priority: major Milestone:
Component: plugin Version:
Keywords: autocomplete xhtml innerHTML createTextNode Cc:
Blocked by: Blocking:
Description

In dataToDom and findValueCallback methods innerHTML properity is used to fill list elements with results. While this is tolerable for

HTML4 formatted pages it breaks plugin in XHTML environment.

Consider server side script returning results that contain ampersand ("A&M" for example). If you return it without modification it'll create the following invalid DOM:

<ul>
<li>A&M</li>
</ul>

(that happens because innerHTML does not properly escape passed value and does not convert & to entity &).

If you return "A&M" from server side script it'll create valid DOM, but will put invalid value in select element ("A&M" instead of "A&M"), so this is not a good solution.

The right thing to do to use document.createTextNode() method instead of innerHTML:

var li = document.createElement("li");
var tn = document.createTextNode(row[0]);
li.appendChild(tn);
Attachments (0)
Change History (2)

Changed May 12, 2008 07:34PM UTC by flesler comment:1

owner: → joern

Changed October 13, 2009 12:09AM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

This is not a jQuery core bug. Please report plugin bugs to the plugin's author, or ask on the jQuery forums. jQuery UI bugs should be reported on the UI bug tracker, http://dev.jqueryui.com .