1
0
mirror of synced 2024-11-26 23:06:02 +03:00

Use tags correctly when set as a function.

This commit is contained in:
Arnar Birgisson 2013-01-23 22:25:34 +01:00
parent 17f9d78e26
commit f49b1006aa

View File

@ -397,17 +397,10 @@ the specific language governing permissions and limitations under the Apache Lic
// TODO javadoc // TODO javadoc
function tags(data) { function tags(data) {
// TODO even for a function we should probably return a wrapper that does the same object/string check as var isFunc = $.isFunction(data);
// the function for arrays. otherwise only functions that return objects are supported.
if ($.isFunction(data)) {
return data;
}
// if not a function we assume it to be an array
return function (query) { return function (query) {
var t = query.term, filtered = {results: []}; var t = query.term, filtered = {results: []};
$(data).each(function () { $(isFunc ? data() : data).each(function () {
var isObject = this.text !== undefined, var isObject = this.text !== undefined,
text = isObject ? this.text : this; text = isObject ? this.text : this;
if (t === "" || query.matcher(t, text)) { if (t === "" || query.matcher(t, text)) {