Skip to content

Commit 660c402

Browse files
committed
Merge pull request select2#738 from arnar/master
Wrap tags correctly when passed as a function.
2 parents 17f9d78 + f49b100 commit 660c402

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

select2.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,10 @@ the specific language governing permissions and limitations under the Apache Lic
397397

398398
// TODO javadoc
399399
function tags(data) {
400-
// TODO even for a function we should probably return a wrapper that does the same object/string check as
401-
// the function for arrays. otherwise only functions that return objects are supported.
402-
if ($.isFunction(data)) {
403-
return data;
404-
}
405-
406-
// if not a function we assume it to be an array
407-
400+
var isFunc = $.isFunction(data);
408401
return function (query) {
409402
var t = query.term, filtered = {results: []};
410-
$(data).each(function () {
403+
$(isFunc ? data() : data).each(function () {
411404
var isObject = this.text !== undefined,
412405
text = isObject ? this.text : this;
413406
if (t === "" || query.matcher(t, text)) {

0 commit comments

Comments
 (0)