jquery/jquery-ui — pull request #929 by bobslee (2013-03-07 11:16:00+00:00)
Title: Allow jQuery objects as labels in autocomplete widgets

In many cases, it's very useful to provide additional feedback in autocompletes, for example to show the part of the returned strings which matches the user's search query in bold.

I realize that this can be done with https://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.html.js but I think it's cleaner if this works similar to how jQuery itself usually works: it can detect that a returned label is a jQuery object and just append it instead of having to choose up front between plain text and html strings.
By detecting jQuery objects, it's always 100% safe (no risk of HTML injection, as long as the source function is well-written), and plain strings and html can be mixed in one result.

This patch allows the "source" option, when a function, to return jQuery labels.