diff --git a/src/js/select2/data/array.js b/src/js/select2/data/array.js
index 99cd8b09..1c9e1bb2 100644
--- a/src/js/select2/data/array.js
+++ b/src/js/select2/data/array.js
@@ -54,7 +54,7 @@ define([
var existingData = this.item($existingOption);
var newData = $.extend(true, {}, existingData, item);
- var $newOption = this.option(existingData);
+ var $newOption = this.option(newData);
$existingOption.replaceWith($newOption);
diff --git a/tests/data/array-tests.js b/tests/data/array-tests.js
index 4107be2d..6096ecfa 100644
--- a/tests/data/array-tests.js
+++ b/tests/data/array-tests.js
@@ -21,6 +21,21 @@ var arrayOptions = new Options({
]
});
+var extraOptions = new Options ({
+ data: [
+ {
+ id: 'default',
+ text: 'Default',
+ extra: true
+ },
+ {
+ id: 'One',
+ text: 'One',
+ extra: true
+ }
+ ]
+});
+
var nestedOptions = new Options({
data: [
{
@@ -206,6 +221,36 @@ test('option tags are automatically generated', function (assert) {
);
});
+test('option tags can receive new data', function(assert) {
+ var $select = $('#qunit-fixture .single');
+
+ var data = new ArrayData($select, extraOptions);
+
+ assert.equal(
+ $select.find('option').length,
+ 2,
+ 'Only one more