From 3c8366e8769233a6b20ade934fe629279e7be6ff Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Mon, 23 Nov 2015 18:55:31 -0500 Subject: [PATCH] Fixed deep cloning options In https://github.com/select2/select2/commit/f1e86470ca08953d802489e6c0e0928674dc08cb we tried to fix the issue where multiple instances created in a single call would share the same options, and this worked for the most common cases. Unfortunately it did not work for the case where data attributes were also used with an options object, and as a result data attributes would be copied to all instances. Data attributes are supposed to be specific to a single instance. This was fixed by moving the `true` for the deep copy to the start of the `$.extend` call, as this is where jQuery looks for the deep copy flag. This closes https://github.com/select2/select2/issues/3485 --- src/js/jquery.select2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/jquery.select2.js b/src/js/jquery.select2.js index b087c94b..8b578fc1 100644 --- a/src/js/jquery.select2.js +++ b/src/js/jquery.select2.js @@ -17,7 +17,7 @@ define([ if (typeof options === 'object') { this.each(function () { - var instanceOptions = $.extend({}, options, true); + var instanceOptions = $.extend(true, {}, options); var instance = new Select2($(this), instanceOptions); });