Skip to content

Commit 222fa7e

Browse files
committed
fix data helper when used with compound choices without a text attribute. fixes select2#370
1 parent 7baa3b9 commit 222fa7e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

select2.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,14 @@
358358
}
359359

360360
process = function(datum, collection) {
361-
var group;
361+
var group, attr;
362362
datum = datum[0];
363363
if (datum.children) {
364-
group = { text: text(datum), children: [] };
364+
group = {};
365+
for (attr in datum) {
366+
if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
367+
}
368+
group.children=[];
365369
$(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
366370
if (group.children.length) {
367371
collection.push(group);

0 commit comments

Comments
 (0)