1
0
mirror of synced 2024-11-26 14:56:07 +03:00

Fixed existing selections not being respected with array data

This fixes an edge case that occurred pretty much whenever anyone would
use array data with existing selections along with a placeholder. This
caused the existing selections to be discarded, because the `selected`
property was not being transferred over to the new option. This was
based the new data was being preferred over the data that could be
inferred from the option, and the new data typically did not include the
selected state. As a result, the option was assumed to not be selected.

This was not cause by existing tests because all of the existing tests
only covered cases where the selected option was the first option, and
that was not affected by this bug.
This commit is contained in:
Kevin Brown 2016-01-03 18:34:59 -05:00
parent d1ed0a513a
commit f3b9693ad9

View File

@ -52,7 +52,7 @@ define([
var $existingOption = $existing.filter(onlyItem(item)); var $existingOption = $existing.filter(onlyItem(item));
var existingData = this.item($existingOption); var existingData = this.item($existingOption);
var newData = $.extend(true, {}, existingData, item); var newData = $.extend(true, {}, item, existingData);
var $newOption = this.option(newData); var $newOption = this.option(newData);