select2-rails 4.0.13 → 4.1.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/select2-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/select2-full.js +310 -671
  5. data/vendor/assets/javascripts/select2.js +308 -269
  6. data/vendor/assets/javascripts/select2_locale_af.js +1 -1
  7. data/vendor/assets/javascripts/select2_locale_ar.js +1 -1
  8. data/vendor/assets/javascripts/select2_locale_az.js +1 -1
  9. data/vendor/assets/javascripts/select2_locale_bg.js +1 -1
  10. data/vendor/assets/javascripts/select2_locale_bn.js +1 -1
  11. data/vendor/assets/javascripts/select2_locale_bs.js +1 -1
  12. data/vendor/assets/javascripts/select2_locale_ca.js +1 -1
  13. data/vendor/assets/javascripts/select2_locale_cs.js +1 -1
  14. data/vendor/assets/javascripts/select2_locale_da.js +1 -1
  15. data/vendor/assets/javascripts/select2_locale_de.js +1 -1
  16. data/vendor/assets/javascripts/select2_locale_dsb.js +1 -1
  17. data/vendor/assets/javascripts/select2_locale_el.js +1 -1
  18. data/vendor/assets/javascripts/select2_locale_en.js +2 -2
  19. data/vendor/assets/javascripts/select2_locale_eo.js +3 -0
  20. data/vendor/assets/javascripts/select2_locale_es.js +1 -1
  21. data/vendor/assets/javascripts/select2_locale_et.js +1 -1
  22. data/vendor/assets/javascripts/select2_locale_eu.js +1 -1
  23. data/vendor/assets/javascripts/select2_locale_fa.js +1 -1
  24. data/vendor/assets/javascripts/select2_locale_fi.js +1 -1
  25. data/vendor/assets/javascripts/select2_locale_fr.js +1 -1
  26. data/vendor/assets/javascripts/select2_locale_gl.js +1 -1
  27. data/vendor/assets/javascripts/select2_locale_he.js +1 -1
  28. data/vendor/assets/javascripts/select2_locale_hi.js +1 -1
  29. data/vendor/assets/javascripts/select2_locale_hr.js +1 -1
  30. data/vendor/assets/javascripts/select2_locale_hsb.js +1 -1
  31. data/vendor/assets/javascripts/select2_locale_hu.js +1 -1
  32. data/vendor/assets/javascripts/select2_locale_hy.js +1 -1
  33. data/vendor/assets/javascripts/select2_locale_id.js +1 -1
  34. data/vendor/assets/javascripts/select2_locale_is.js +1 -1
  35. data/vendor/assets/javascripts/select2_locale_it.js +1 -1
  36. data/vendor/assets/javascripts/select2_locale_ja.js +1 -1
  37. data/vendor/assets/javascripts/select2_locale_ka.js +1 -1
  38. data/vendor/assets/javascripts/select2_locale_km.js +1 -1
  39. data/vendor/assets/javascripts/select2_locale_ko.js +1 -1
  40. data/vendor/assets/javascripts/select2_locale_lt.js +1 -1
  41. data/vendor/assets/javascripts/select2_locale_lv.js +1 -1
  42. data/vendor/assets/javascripts/select2_locale_mk.js +1 -1
  43. data/vendor/assets/javascripts/select2_locale_ms.js +1 -1
  44. data/vendor/assets/javascripts/select2_locale_nb.js +1 -1
  45. data/vendor/assets/javascripts/select2_locale_ne.js +1 -1
  46. data/vendor/assets/javascripts/select2_locale_nl.js +1 -1
  47. data/vendor/assets/javascripts/select2_locale_pa.js +3 -0
  48. data/vendor/assets/javascripts/select2_locale_pl.js +1 -1
  49. data/vendor/assets/javascripts/select2_locale_ps.js +1 -1
  50. data/vendor/assets/javascripts/select2_locale_pt-BR.js +1 -1
  51. data/vendor/assets/javascripts/select2_locale_pt.js +1 -1
  52. data/vendor/assets/javascripts/select2_locale_ro.js +1 -1
  53. data/vendor/assets/javascripts/select2_locale_ru.js +1 -1
  54. data/vendor/assets/javascripts/select2_locale_sk.js +1 -1
  55. data/vendor/assets/javascripts/select2_locale_sl.js +1 -1
  56. data/vendor/assets/javascripts/select2_locale_sq.js +1 -1
  57. data/vendor/assets/javascripts/select2_locale_sr-Cyrl.js +1 -1
  58. data/vendor/assets/javascripts/select2_locale_sr.js +1 -1
  59. data/vendor/assets/javascripts/select2_locale_sv.js +1 -1
  60. data/vendor/assets/javascripts/select2_locale_th.js +1 -1
  61. data/vendor/assets/javascripts/select2_locale_tk.js +1 -1
  62. data/vendor/assets/javascripts/select2_locale_tr.js +1 -1
  63. data/vendor/assets/javascripts/select2_locale_uk.js +1 -1
  64. data/vendor/assets/javascripts/select2_locale_vi.js +1 -1
  65. data/vendor/assets/javascripts/select2_locale_zh-CN.js +1 -1
  66. data/vendor/assets/javascripts/select2_locale_zh-TW.js +1 -1
  67. data/vendor/assets/stylesheets/select2.css +103 -69
  68. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c74819abcc9a780c3221badc68cc4d2bc999e016c8d3a412c6c197545451126c
4
- data.tar.gz: 1b22502c83b69ebbe348018e3e069aa640f160fd0e99c385c6d18064bd662ffa
3
+ metadata.gz: fc63c98004a81bcbada24c6f86fb04467186e4273d2caf2acbf834a4750bfa1b
4
+ data.tar.gz: 44b43109d599ba5e6f854e3cf3f5ae68a8ac7e40fe82a8335c1f43549325b63e
5
5
  SHA512:
6
- metadata.gz: 044aca6303e13dee71f8e2532db1369fd757fb58cda8945e9f7d20a1244205a75c8a72e4fed02a4e768ff7379a9a0579ed0735baa9fb421c11a5c2722481ed4b
7
- data.tar.gz: 2fc02500109a54e3d47fddccfe6d477741e4f3e9bb6b2a937cffc658c4eec2777940ba3ee66bc436645eb7bcb6d6e11e580460c15abf2b982bc86c9575bdbcce
6
+ metadata.gz: 6f0562e6f4a652e22168fb340d61a0e8dc4843140b3cf04988b66a8f9d51406b396d2b3787658d2981a501bfe4721177b27ffd2206b8683ed9b3695c2056d37f
7
+ data.tar.gz: 25f80632ed6fe45d70da0771086a037d7d717b88405d8332d3434a6d5d3080095f63325aa7f118b55237bb8fcfe0a15da6520c4e68a38d20111f4ed34252234d
data/README.md CHANGED
@@ -56,7 +56,7 @@ To apply the language, pass whatever language you'd like to use to the [`languag
56
56
 
57
57
  Possible languages:
58
58
 
59
- af, ar, az, bg, bn, bs, ca, cs, da, de, dsb, el, en, es, et, eu, fa, fi, fr, gl, he, hi, hr, hsb, hu, hy, id, is, it, ja, ka, km, ko, lt, lv, mk, ms, nb, ne, nl, pl, ps, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-Cyrl, sv, th, tk, tr, uk, vi, zh-CN, zh-TW
59
+ af, ar, az, bg, bn, bs, ca, cs, da, de, dsb, el, en, eo, es, et, eu, fa, fi, fr, gl, he, hi, hr, hsb, hu, hy, id, is, it, ja, ka, km, ko, lt, lv, mk, ms, nb, ne, nl, pa, pl, ps, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-Cyrl, sv, th, tk, tr, uk, vi, zh-CN, zh-TW
60
60
 
61
61
  ## Example
62
62
  Code [here](https://github.com/argerim/select_2_example)
@@ -1,5 +1,5 @@
1
1
  module Select2
2
2
  module Rails
3
- VERSION = '4.0.13'
3
+ VERSION = '4.1.0-beta.1'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Select2 4.0.13
2
+ * Select2 4.1.0-beta.1
3
3
  * https://select2.github.io
4
4
  *
5
5
  * Released under the MIT license
@@ -755,23 +755,6 @@ S2.define('select2/utils',[
755
755
  });
756
756
  };
757
757
 
758
- // Append an array of jQuery nodes to a given element.
759
- Utils.appendMany = function ($element, $nodes) {
760
- // jQuery 1.7.x does not support $.fn.append() with an array
761
- // Fall back to a jQuery object collection using $.fn.add()
762
- if ($.fn.jquery.substr(0, 3) === '1.7') {
763
- var $jqNodes = $();
764
-
765
- $.map($nodes, function (node) {
766
- $jqNodes = $jqNodes.add(node);
767
- });
768
-
769
- $nodes = $jqNodes;
770
- }
771
-
772
- $element.append($nodes);
773
- };
774
-
775
758
  // Cache objects in Utils.__cache instead of $.data (see #4346)
776
759
  Utils.__cache = {};
777
760
 
@@ -779,20 +762,25 @@ S2.define('select2/utils',[
779
762
  Utils.GetUniqueElementId = function (element) {
780
763
  // Get a unique element Id. If element has no id,
781
764
  // creates a new unique number, stores it in the id
782
- // attribute and returns the new id.
783
- // If an id already exists, it simply returns it.
765
+ // attribute and returns the new id with a prefix.
766
+ // If an id already exists, it simply returns it with a prefix.
784
767
 
785
768
  var select2Id = element.getAttribute('data-select2-id');
786
- if (select2Id == null) {
787
- // If element has id, use it.
788
- if (element.id) {
789
- select2Id = element.id;
790
- element.setAttribute('data-select2-id', select2Id);
791
- } else {
792
- element.setAttribute('data-select2-id', ++id);
793
- select2Id = id.toString();
794
- }
769
+
770
+ if (select2Id != null) {
771
+ return select2Id;
772
+ }
773
+
774
+ // If element has id, use it.
775
+ if (element.id) {
776
+ select2Id = 'select2-data-' + element.id;
777
+ } else {
778
+ select2Id = 'select2-data-' + (++id).toString() +
779
+ '-' + Utils.generateChars(4);
795
780
  }
781
+
782
+ element.setAttribute('data-select2-id', select2Id);
783
+
796
784
  return select2Id;
797
785
  };
798
786
 
@@ -836,6 +824,28 @@ S2.define('select2/utils',[
836
824
  element.removeAttribute('data-select2-id');
837
825
  };
838
826
 
827
+ Utils.copyNonInternalCssClasses = function (dest, src) {
828
+ var classes;
829
+
830
+ var destinationClasses = dest.getAttribute('class').trim().split(/\s+/);
831
+
832
+ destinationClasses = destinationClasses.filter(function (clazz) {
833
+ // Save all Select2 classes
834
+ return clazz.indexOf('select2-') === 0;
835
+ });
836
+
837
+ var sourceClasses = src.getAttribute('class').trim().split(/\s+/);
838
+
839
+ sourceClasses = sourceClasses.filter(function (clazz) {
840
+ // Only copy non-Select2 classes
841
+ return clazz.indexOf('select2-') !== 0;
842
+ });
843
+
844
+ var replacements = destinationClasses.concat(sourceClasses);
845
+
846
+ dest.setAttribute('class', replacements.join(' '));
847
+ };
848
+
839
849
  return Utils;
840
850
  });
841
851
 
@@ -940,9 +950,9 @@ S2.define('select2/results',[
940
950
 
941
951
  Results.prototype.highlightFirstItem = function () {
942
952
  var $options = this.$results
943
- .find('.select2-results__option[aria-selected]');
953
+ .find('.select2-results__option--selectable');
944
954
 
945
- var $selected = $options.filter('[aria-selected=true]');
955
+ var $selected = $options.filter('.select2-results__option--selected');
946
956
 
947
957
  // Check if there are any selected options
948
958
  if ($selected.length > 0) {
@@ -961,12 +971,12 @@ S2.define('select2/results',[
961
971
  var self = this;
962
972
 
963
973
  this.data.current(function (selected) {
964
- var selectedIds = $.map(selected, function (s) {
974
+ var selectedIds = selected.map(function (s) {
965
975
  return s.id.toString();
966
976
  });
967
977
 
968
978
  var $options = self.$results
969
- .find('.select2-results__option[aria-selected]');
979
+ .find('.select2-results__option--selectable');
970
980
 
971
981
  $options.each(function () {
972
982
  var $option = $(this);
@@ -977,9 +987,11 @@ S2.define('select2/results',[
977
987
  var id = '' + item.id;
978
988
 
979
989
  if ((item.element != null && item.element.selected) ||
980
- (item.element == null && $.inArray(id, selectedIds) > -1)) {
990
+ (item.element == null && selectedIds.indexOf(id) > -1)) {
991
+ this.classList.add('select2-results__option--selected');
981
992
  $option.attr('aria-selected', 'true');
982
993
  } else {
994
+ this.classList.remove('select2-results__option--selected');
983
995
  $option.attr('aria-selected', 'false');
984
996
  }
985
997
  });
@@ -1009,11 +1021,11 @@ S2.define('select2/results',[
1009
1021
 
1010
1022
  Results.prototype.option = function (data) {
1011
1023
  var option = document.createElement('li');
1012
- option.className = 'select2-results__option';
1024
+ option.classList.add('select2-results__option');
1025
+ option.classList.add('select2-results__option--selectable');
1013
1026
 
1014
1027
  var attrs = {
1015
- 'role': 'option',
1016
- 'aria-selected': 'false'
1028
+ 'role': 'option'
1017
1029
  };
1018
1030
 
1019
1031
  var matches = window.Element.prototype.matches ||
@@ -1022,12 +1034,14 @@ S2.define('select2/results',[
1022
1034
 
1023
1035
  if ((data.element != null && matches.call(data.element, ':disabled')) ||
1024
1036
  (data.element == null && data.disabled)) {
1025
- delete attrs['aria-selected'];
1026
1037
  attrs['aria-disabled'] = 'true';
1038
+
1039
+ option.classList.remove('select2-results__option--selectable');
1040
+ option.classList.add('select2-results__option--disabled');
1027
1041
  }
1028
1042
 
1029
1043
  if (data.id == null) {
1030
- delete attrs['aria-selected'];
1044
+ option.classList.remove('select2-results__option--selectable');
1031
1045
  }
1032
1046
 
1033
1047
  if (data._resultId != null) {
@@ -1041,7 +1055,9 @@ S2.define('select2/results',[
1041
1055
  if (data.children) {
1042
1056
  attrs.role = 'group';
1043
1057
  attrs['aria-label'] = data.text;
1044
- delete attrs['aria-selected'];
1058
+
1059
+ option.classList.remove('select2-results__option--selectable');
1060
+ option.classList.add('select2-results__option--group');
1045
1061
  }
1046
1062
 
1047
1063
  for (var attr in attrs) {
@@ -1056,7 +1072,6 @@ S2.define('select2/results',[
1056
1072
  var label = document.createElement('strong');
1057
1073
  label.className = 'select2-results__group';
1058
1074
 
1059
- var $label = $(label);
1060
1075
  this.template(data, label);
1061
1076
 
1062
1077
  var $children = [];
@@ -1175,7 +1190,7 @@ S2.define('select2/results',[
1175
1190
 
1176
1191
  var data = Utils.GetData($highlighted[0], 'data');
1177
1192
 
1178
- if ($highlighted.attr('aria-selected') == 'true') {
1193
+ if ($highlighted.hasClass('select2-results__option--selected')) {
1179
1194
  self.trigger('close', {});
1180
1195
  } else {
1181
1196
  self.trigger('select', {
@@ -1187,7 +1202,7 @@ S2.define('select2/results',[
1187
1202
  container.on('results:previous', function () {
1188
1203
  var $highlighted = self.getHighlightedResults();
1189
1204
 
1190
- var $options = self.$results.find('[aria-selected]');
1205
+ var $options = self.$results.find('.select2-results__option--selectable');
1191
1206
 
1192
1207
  var currentIndex = $options.index($highlighted);
1193
1208
 
@@ -1222,7 +1237,7 @@ S2.define('select2/results',[
1222
1237
  container.on('results:next', function () {
1223
1238
  var $highlighted = self.getHighlightedResults();
1224
1239
 
1225
- var $options = self.$results.find('[aria-selected]');
1240
+ var $options = self.$results.find('.select2-results__option--selectable');
1226
1241
 
1227
1242
  var currentIndex = $options.index($highlighted);
1228
1243
 
@@ -1250,7 +1265,8 @@ S2.define('select2/results',[
1250
1265
  });
1251
1266
 
1252
1267
  container.on('results:focus', function (params) {
1253
- params.element.addClass('select2-results__option--highlighted');
1268
+ params.element[0].classList.add('select2-results__option--highlighted');
1269
+ params.element[0].setAttribute('aria-selected', 'true');
1254
1270
  });
1255
1271
 
1256
1272
  container.on('results:message', function (params) {
@@ -1282,13 +1298,13 @@ S2.define('select2/results',[
1282
1298
  });
1283
1299
  }
1284
1300
 
1285
- this.$results.on('mouseup', '.select2-results__option[aria-selected]',
1301
+ this.$results.on('mouseup', '.select2-results__option--selectable',
1286
1302
  function (evt) {
1287
1303
  var $this = $(this);
1288
1304
 
1289
1305
  var data = Utils.GetData(this, 'data');
1290
1306
 
1291
- if ($this.attr('aria-selected') === 'true') {
1307
+ if ($this.hasClass('select2-results__option--selected')) {
1292
1308
  if (self.options.get('multiple')) {
1293
1309
  self.trigger('unselect', {
1294
1310
  originalEvent: evt,
@@ -1307,12 +1323,13 @@ S2.define('select2/results',[
1307
1323
  });
1308
1324
  });
1309
1325
 
1310
- this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
1326
+ this.$results.on('mouseenter', '.select2-results__option--selectable',
1311
1327
  function (evt) {
1312
1328
  var data = Utils.GetData(this, 'data');
1313
1329
 
1314
1330
  self.getHighlightedResults()
1315
- .removeClass('select2-results__option--highlighted');
1331
+ .removeClass('select2-results__option--highlighted')
1332
+ .attr('aria-selected', 'false');
1316
1333
 
1317
1334
  self.trigger('results:focus', {
1318
1335
  data: data,
@@ -1339,7 +1356,7 @@ S2.define('select2/results',[
1339
1356
  return;
1340
1357
  }
1341
1358
 
1342
- var $options = this.$results.find('[aria-selected]');
1359
+ var $options = this.$results.find('.select2-results__option--selectable');
1343
1360
 
1344
1361
  var currentIndex = $options.index($highlighted);
1345
1362
 
@@ -1595,7 +1612,7 @@ S2.define('select2/selection/single',[
1595
1612
  SingleSelection.prototype.render = function () {
1596
1613
  var $selection = SingleSelection.__super__.render.call(this);
1597
1614
 
1598
- $selection.addClass('select2-selection--single');
1615
+ $selection[0].classList.add('select2-selection--single');
1599
1616
 
1600
1617
  $selection.html(
1601
1618
  '<span class="select2-selection__rendered"></span>' +
@@ -1702,7 +1719,7 @@ S2.define('select2/selection/multiple',[
1702
1719
  MultipleSelection.prototype.render = function () {
1703
1720
  var $selection = MultipleSelection.__super__.render.call(this);
1704
1721
 
1705
- $selection.addClass('select2-selection--multiple');
1722
+ $selection[0].classList.add('select2-selection--multiple');
1706
1723
 
1707
1724
  $selection.html(
1708
1725
  '<ul class="select2-selection__rendered"></ul>'
@@ -1716,6 +1733,9 @@ S2.define('select2/selection/multiple',[
1716
1733
 
1717
1734
  MultipleSelection.__super__.bind.apply(this, arguments);
1718
1735
 
1736
+ var id = container.id + '-container';
1737
+ this.$selection.find('.select2-selection__rendered').attr('id', id);
1738
+
1719
1739
  this.$selection.on('click', function (evt) {
1720
1740
  self.trigger('toggle', {
1721
1741
  originalEvent: evt
@@ -1742,6 +1762,19 @@ S2.define('select2/selection/multiple',[
1742
1762
  });
1743
1763
  }
1744
1764
  );
1765
+
1766
+ this.$selection.on(
1767
+ 'keydown',
1768
+ '.select2-selection__choice__remove',
1769
+ function (evt) {
1770
+ // Ignore the event if it is disabled
1771
+ if (self.isDisabled()) {
1772
+ return;
1773
+ }
1774
+
1775
+ evt.stopPropagation();
1776
+ }
1777
+ );
1745
1778
  };
1746
1779
 
1747
1780
  MultipleSelection.prototype.clear = function () {
@@ -1760,9 +1793,11 @@ S2.define('select2/selection/multiple',[
1760
1793
  MultipleSelection.prototype.selectionContainer = function () {
1761
1794
  var $container = $(
1762
1795
  '<li class="select2-selection__choice">' +
1763
- '<span class="select2-selection__choice__remove" role="presentation">' +
1764
- '&times;' +
1765
- '</span>' +
1796
+ '<button type="button" class="select2-selection__choice__remove" ' +
1797
+ 'tabindex="-1">' +
1798
+ '<span aria-hidden="true">&times;</span>' +
1799
+ '</button>' +
1800
+ '<span class="select2-selection__choice__display"></span>' +
1766
1801
  '</li>'
1767
1802
  );
1768
1803
 
@@ -1778,13 +1813,26 @@ S2.define('select2/selection/multiple',[
1778
1813
 
1779
1814
  var $selections = [];
1780
1815
 
1816
+ var selectionIdPrefix = this.$selection.find('.select2-selection__rendered')
1817
+ .attr('id') + '-choice-';
1818
+
1781
1819
  for (var d = 0; d < data.length; d++) {
1782
1820
  var selection = data[d];
1783
1821
 
1784
1822
  var $selection = this.selectionContainer();
1785
1823
  var formatted = this.display(selection, $selection);
1786
1824
 
1787
- $selection.append(formatted);
1825
+ var selectionId = selectionIdPrefix + Utils.generateChars(4) + '-';
1826
+
1827
+ if (selection.id) {
1828
+ selectionId += selection.id;
1829
+ } else {
1830
+ selectionId += Utils.generateChars(4);
1831
+ }
1832
+
1833
+ $selection.find('.select2-selection__choice__display')
1834
+ .append(formatted)
1835
+ .attr('id', selectionId);
1788
1836
 
1789
1837
  var title = selection.title || selection.text;
1790
1838
 
@@ -1792,6 +1840,14 @@ S2.define('select2/selection/multiple',[
1792
1840
  $selection.attr('title', title);
1793
1841
  }
1794
1842
 
1843
+ var removeItem = this.options.get('translations').get('removeItem');
1844
+
1845
+ var $remove = $selection.find('.select2-selection__choice__remove');
1846
+
1847
+ $remove.attr('title', removeItem());
1848
+ $remove.attr('aria-label', removeItem());
1849
+ $remove.attr('aria-describedby', selectionId);
1850
+
1795
1851
  Utils.StoreData($selection[0], 'data', selection);
1796
1852
 
1797
1853
  $selections.push($selection);
@@ -1799,15 +1855,15 @@ S2.define('select2/selection/multiple',[
1799
1855
 
1800
1856
  var $rendered = this.$selection.find('.select2-selection__rendered');
1801
1857
 
1802
- Utils.appendMany($rendered, $selections);
1858
+ $rendered.append($selections);
1803
1859
  };
1804
1860
 
1805
1861
  return MultipleSelection;
1806
1862
  });
1807
1863
 
1808
1864
  S2.define('select2/selection/placeholder',[
1809
- '../utils'
1810
- ], function (Utils) {
1865
+
1866
+ ], function () {
1811
1867
  function Placeholder (decorated, $element, options) {
1812
1868
  this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
1813
1869
 
@@ -1829,8 +1885,8 @@ S2.define('select2/selection/placeholder',[
1829
1885
  var $placeholder = this.selectionContainer();
1830
1886
 
1831
1887
  $placeholder.html(this.display(placeholder));
1832
- $placeholder.addClass('select2-selection__placeholder')
1833
- .removeClass('select2-selection__choice');
1888
+ $placeholder[0].classList.add('select2-selection__placeholder');
1889
+ $placeholder[0].classList.remove('select2-selection__choice');
1834
1890
 
1835
1891
  return $placeholder;
1836
1892
  };
@@ -1949,21 +2005,29 @@ S2.define('select2/selection/allowClear',[
1949
2005
  AllowClear.prototype.update = function (decorated, data) {
1950
2006
  decorated.call(this, data);
1951
2007
 
2008
+ this.$selection.find('.select2-selection__clear').remove();
2009
+
1952
2010
  if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
1953
2011
  data.length === 0) {
1954
2012
  return;
1955
2013
  }
1956
2014
 
2015
+ var selectionId = this.$selection.find('.select2-selection__rendered')
2016
+ .attr('id');
2017
+
1957
2018
  var removeAll = this.options.get('translations').get('removeAllItems');
1958
2019
 
1959
2020
  var $remove = $(
1960
- '<span class="select2-selection__clear" title="' + removeAll() +'">' +
1961
- '&times;' +
1962
- '</span>'
2021
+ '<button type="button" class="select2-selection__clear" tabindex="-1">' +
2022
+ '<span aria-hidden="true">&times;</span>' +
2023
+ '</button>'
1963
2024
  );
2025
+ $remove.attr('title', removeAll());
2026
+ $remove.attr('aria-label', removeAll());
2027
+ $remove.attr('aria-describedby', selectionId);
1964
2028
  Utils.StoreData($remove[0], 'data', data);
1965
2029
 
1966
- this.$selection.find('.select2-selection__rendered').prepend($remove);
2030
+ this.$selection.prepend($remove);
1967
2031
  };
1968
2032
 
1969
2033
  return AllowClear;
@@ -1980,19 +2044,22 @@ S2.define('select2/selection/search',[
1980
2044
 
1981
2045
  Search.prototype.render = function (decorated) {
1982
2046
  var $search = $(
1983
- '<li class="select2-search select2-search--inline">' +
2047
+ '<span class="select2-search select2-search--inline">' +
1984
2048
  '<input class="select2-search__field" type="search" tabindex="-1"' +
1985
- ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
2049
+ ' autocorrect="off" autocapitalize="none"' +
1986
2050
  ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
1987
- '</li>'
2051
+ '</span>'
1988
2052
  );
1989
2053
 
1990
2054
  this.$searchContainer = $search;
1991
2055
  this.$search = $search.find('input');
1992
2056
 
2057
+ this.$search.prop('autocomplete', this.options.get('autocomplete'));
2058
+
1993
2059
  var $rendered = decorated.call(this);
1994
2060
 
1995
2061
  this._transferTabIndex();
2062
+ $rendered.append(this.$searchContainer);
1996
2063
 
1997
2064
  return $rendered;
1998
2065
  };
@@ -2001,9 +2068,12 @@ S2.define('select2/selection/search',[
2001
2068
  var self = this;
2002
2069
 
2003
2070
  var resultsId = container.id + '-results';
2071
+ var selectionId = container.id + '-container';
2004
2072
 
2005
2073
  decorated.call(this, container, $container);
2006
2074
 
2075
+ self.$search.attr('aria-describedby', selectionId);
2076
+
2007
2077
  container.on('open', function () {
2008
2078
  self.$search.attr('aria-controls', resultsId);
2009
2079
  self.$search.trigger('focus');
@@ -2011,6 +2081,7 @@ S2.define('select2/selection/search',[
2011
2081
 
2012
2082
  container.on('close', function () {
2013
2083
  self.$search.val('');
2084
+ self.resizeSearch();
2014
2085
  self.$search.removeAttr('aria-controls');
2015
2086
  self.$search.removeAttr('aria-activedescendant');
2016
2087
  self.$search.trigger('focus');
@@ -2056,8 +2127,8 @@ S2.define('select2/selection/search',[
2056
2127
  var key = evt.which;
2057
2128
 
2058
2129
  if (key === KEYS.BACKSPACE && self.$search.val() === '') {
2059
- var $previousChoice = self.$searchContainer
2060
- .prev('.select2-selection__choice');
2130
+ var $previousChoice = self.$selection
2131
+ .find('.select2-selection__choice').last();
2061
2132
 
2062
2133
  if ($previousChoice.length > 0) {
2063
2134
  var item = Utils.GetData($previousChoice[0], 'data');
@@ -2155,9 +2226,6 @@ S2.define('select2/selection/search',[
2155
2226
 
2156
2227
  decorated.call(this, data);
2157
2228
 
2158
- this.$selection.find('.select2-selection__rendered')
2159
- .append(this.$searchContainer);
2160
-
2161
2229
  this.resizeSearch();
2162
2230
  if (searchHadFocus) {
2163
2231
  this.$search.trigger('focus');
@@ -2190,11 +2258,9 @@ S2.define('select2/selection/search',[
2190
2258
  Search.prototype.resizeSearch = function () {
2191
2259
  this.$search.css('width', '25px');
2192
2260
 
2193
- var width = '';
2261
+ var width = '100%';
2194
2262
 
2195
- if (this.$search.attr('placeholder') !== '') {
2196
- width = this.$selection.find('.select2-selection__rendered').width();
2197
- } else {
2263
+ if (this.$search.attr('placeholder') === '') {
2198
2264
  var minimumWidth = this.$search.val().length + 1;
2199
2265
 
2200
2266
  width = (minimumWidth * 0.75) + 'em';
@@ -2206,6 +2272,30 @@ S2.define('select2/selection/search',[
2206
2272
  return Search;
2207
2273
  });
2208
2274
 
2275
+ S2.define('select2/selection/selectionCss',[
2276
+ '../utils'
2277
+ ], function (Utils) {
2278
+ function SelectionCSS () { }
2279
+
2280
+ SelectionCSS.prototype.render = function (decorated) {
2281
+ var $selection = decorated.call(this);
2282
+
2283
+ var selectionCssClass = this.options.get('selectionCssClass') || '';
2284
+
2285
+ if (selectionCssClass.indexOf(':all:') !== -1) {
2286
+ selectionCssClass = selectionCssClass.replace(':all:', '');
2287
+
2288
+ Utils.copyNonInternalCssClasses($selection[0], this.$element[0]);
2289
+ }
2290
+
2291
+ $selection.addClass(selectionCssClass);
2292
+
2293
+ return $selection;
2294
+ };
2295
+
2296
+ return SelectionCSS;
2297
+ });
2298
+
2209
2299
  S2.define('select2/selection/eventRelay',[
2210
2300
  'jquery'
2211
2301
  ], function ($) {
@@ -2229,7 +2319,7 @@ S2.define('select2/selection/eventRelay',[
2229
2319
 
2230
2320
  container.on('*', function (name, params) {
2231
2321
  // Ignore events that should not be relayed
2232
- if ($.inArray(name, relayEvents) === -1) {
2322
+ if (relayEvents.indexOf(name) === -1) {
2233
2323
  return;
2234
2324
  }
2235
2325
 
@@ -2244,7 +2334,7 @@ S2.define('select2/selection/eventRelay',[
2244
2334
  self.$element.trigger(evt);
2245
2335
 
2246
2336
  // Only handle preventable events if it was one
2247
- if ($.inArray(name, preventableEvents) === -1) {
2337
+ if (preventableEvents.indexOf(name) === -1) {
2248
2338
  return;
2249
2339
  }
2250
2340
 
@@ -3199,16 +3289,14 @@ S2.define('select2/data/select',[
3199
3289
  Utils.Extend(SelectAdapter, BaseAdapter);
3200
3290
 
3201
3291
  SelectAdapter.prototype.current = function (callback) {
3202
- var data = [];
3203
3292
  var self = this;
3204
3293
 
3205
- this.$element.find(':selected').each(function () {
3206
- var $option = $(this);
3207
-
3208
- var option = self.item($option);
3209
-
3210
- data.push(option);
3211
- });
3294
+ var data = Array.prototype.map.call(
3295
+ this.$element[0].querySelectorAll(':checked'),
3296
+ function (selectedElement) {
3297
+ return self.item($(selectedElement));
3298
+ }
3299
+ );
3212
3300
 
3213
3301
  callback(data);
3214
3302
  };
@@ -3219,7 +3307,9 @@ S2.define('select2/data/select',[
3219
3307
  data.selected = true;
3220
3308
 
3221
3309
  // If data.element is a DOM node, use it instead
3222
- if ($(data.element).is('option')) {
3310
+ if (
3311
+ data.element != null && data.element.tagName.toLowerCase() === 'option'
3312
+ ) {
3223
3313
  data.element.selected = true;
3224
3314
 
3225
3315
  this.$element.trigger('input').trigger('change');
@@ -3237,7 +3327,7 @@ S2.define('select2/data/select',[
3237
3327
  for (var d = 0; d < data.length; d++) {
3238
3328
  var id = data[d].id;
3239
3329
 
3240
- if ($.inArray(id, val) === -1) {
3330
+ if (val.indexOf(id) === -1) {
3241
3331
  val.push(id);
3242
3332
  }
3243
3333
  }
@@ -3262,7 +3352,10 @@ S2.define('select2/data/select',[
3262
3352
 
3263
3353
  data.selected = false;
3264
3354
 
3265
- if ($(data.element).is('option')) {
3355
+ if (
3356
+ data.element != null &&
3357
+ data.element.tagName.toLowerCase() === 'option'
3358
+ ) {
3266
3359
  data.element.selected = false;
3267
3360
 
3268
3361
  this.$element.trigger('input').trigger('change');
@@ -3276,7 +3369,7 @@ S2.define('select2/data/select',[
3276
3369
  for (var d = 0; d < currentData.length; d++) {
3277
3370
  var id = currentData[d].id;
3278
3371
 
3279
- if (id !== data.id && $.inArray(id, val) === -1) {
3372
+ if (id !== data.id && val.indexOf(id) === -1) {
3280
3373
  val.push(id);
3281
3374
  }
3282
3375
  }
@@ -3316,12 +3409,15 @@ S2.define('select2/data/select',[
3316
3409
  var $options = this.$element.children();
3317
3410
 
3318
3411
  $options.each(function () {
3319
- var $option = $(this);
3320
-
3321
- if (!$option.is('option') && !$option.is('optgroup')) {
3412
+ if (
3413
+ this.tagName.toLowerCase() !== 'option' &&
3414
+ this.tagName.toLowerCase() !== 'optgroup'
3415
+ ) {
3322
3416
  return;
3323
3417
  }
3324
3418
 
3419
+ var $option = $(this);
3420
+
3325
3421
  var option = self.item($option);
3326
3422
 
3327
3423
  var matches = self.matches(params, option);
@@ -3337,7 +3433,7 @@ S2.define('select2/data/select',[
3337
3433
  };
3338
3434
 
3339
3435
  SelectAdapter.prototype.addOptions = function ($options) {
3340
- Utils.appendMany(this.$element, $options);
3436
+ this.$element.append($options);
3341
3437
  };
3342
3438
 
3343
3439
  SelectAdapter.prototype.option = function (data) {
@@ -3372,15 +3468,13 @@ S2.define('select2/data/select',[
3372
3468
  option.title = data.title;
3373
3469
  }
3374
3470
 
3375
- var $option = $(option);
3376
-
3377
3471
  var normalizedData = this._normalizeItem(data);
3378
3472
  normalizedData.element = option;
3379
3473
 
3380
3474
  // Override the option's data with the combined data
3381
3475
  Utils.StoreData(option, 'data', normalizedData);
3382
3476
 
3383
- return $option;
3477
+ return $(option);
3384
3478
  };
3385
3479
 
3386
3480
  SelectAdapter.prototype.item = function ($option) {
@@ -3392,7 +3486,9 @@ S2.define('select2/data/select',[
3392
3486
  return data;
3393
3487
  }
3394
3488
 
3395
- if ($option.is('option')) {
3489
+ var option = $option[0];
3490
+
3491
+ if (option.tagName.toLowerCase() === 'option') {
3396
3492
  data = {
3397
3493
  id: $option.val(),
3398
3494
  text: $option.text(),
@@ -3400,7 +3496,7 @@ S2.define('select2/data/select',[
3400
3496
  selected: $option.prop('selected'),
3401
3497
  title: $option.prop('title')
3402
3498
  };
3403
- } else if ($option.is('optgroup')) {
3499
+ } else if (option.tagName.toLowerCase() === 'optgroup') {
3404
3500
  data = {
3405
3501
  text: $option.prop('label'),
3406
3502
  children: [],
@@ -3524,7 +3620,7 @@ S2.define('select2/data/array',[
3524
3620
  var item = this._normalizeItem(data[d]);
3525
3621
 
3526
3622
  // Skip items which were pre-loaded, only merge the data
3527
- if ($.inArray(item.id, existingIds) >= 0) {
3623
+ if (existingIds.indexOf(item.id) >= 0) {
3528
3624
  var $existingOption = $existing.filter(onlyItem(item));
3529
3625
 
3530
3626
  var existingData = this.item($existingOption);
@@ -3542,7 +3638,7 @@ S2.define('select2/data/array',[
3542
3638
  if (item.children) {
3543
3639
  var $children = this.convertToOptions(item.children);
3544
3640
 
3545
- Utils.appendMany($option, $children);
3641
+ $option.append($children);
3546
3642
  }
3547
3643
 
3548
3644
  $options.push($option);
@@ -3626,7 +3722,7 @@ S2.define('select2/data/ajax',[
3626
3722
 
3627
3723
  if (self.options.get('debug') && window.console && console.error) {
3628
3724
  // Check to make sure that the response included a `results` key.
3629
- if (!results || !results.results || !$.isArray(results.results)) {
3725
+ if (!results || !results.results || !Array.isArray(results.results)) {
3630
3726
  console.error(
3631
3727
  'Select2: The AJAX results did not return an array in the ' +
3632
3728
  '`results` key of the response.'
@@ -3685,7 +3781,7 @@ S2.define('select2/data/tags',[
3685
3781
 
3686
3782
  decorated.call(this, $element, options);
3687
3783
 
3688
- if ($.isArray(tags)) {
3784
+ if (Array.isArray(tags)) {
3689
3785
  for (var t = 0; t < tags.length; t++) {
3690
3786
  var tag = tags[t];
3691
3787
  var item = this._normalizeItem(tag);
@@ -3761,7 +3857,11 @@ S2.define('select2/data/tags',[
3761
3857
  };
3762
3858
 
3763
3859
  Tags.prototype.createTag = function (decorated, params) {
3764
- var term = $.trim(params.term);
3860
+ if (params.term == null) {
3861
+ return null;
3862
+ }
3863
+
3864
+ var term = params.term.trim();
3765
3865
 
3766
3866
  if (term === '') {
3767
3867
  return null;
@@ -3876,7 +3976,7 @@ S2.define('select2/data/tokenizer',[
3876
3976
  while (i < term.length) {
3877
3977
  var termChar = term[i];
3878
3978
 
3879
- if ($.inArray(termChar, separators) === -1) {
3979
+ if (separators.indexOf(termChar) === -1) {
3880
3980
  i++;
3881
3981
 
3882
3982
  continue;
@@ -4071,9 +4171,8 @@ S2.define('select2/dropdown',[
4071
4171
  });
4072
4172
 
4073
4173
  S2.define('select2/dropdown/search',[
4074
- 'jquery',
4075
- '../utils'
4076
- ], function ($, Utils) {
4174
+ 'jquery'
4175
+ ], function ($) {
4077
4176
  function Search () { }
4078
4177
 
4079
4178
  Search.prototype.render = function (decorated) {
@@ -4082,7 +4181,7 @@ S2.define('select2/dropdown/search',[
4082
4181
  var $search = $(
4083
4182
  '<span class="select2-search select2-search--dropdown">' +
4084
4183
  '<input class="select2-search__field" type="search" tabindex="-1"' +
4085
- ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
4184
+ ' autocorrect="off" autocapitalize="none"' +
4086
4185
  ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
4087
4186
  '</span>'
4088
4187
  );
@@ -4090,6 +4189,8 @@ S2.define('select2/dropdown/search',[
4090
4189
  this.$searchContainer = $search;
4091
4190
  this.$search = $search.find('input');
4092
4191
 
4192
+ this.$search.prop('autocomplete', this.options.get('autocomplete'));
4193
+
4093
4194
  $rendered.prepend($search);
4094
4195
 
4095
4196
  return $rendered;
@@ -4151,9 +4252,9 @@ S2.define('select2/dropdown/search',[
4151
4252
  var showSearch = self.showSearch(params);
4152
4253
 
4153
4254
  if (showSearch) {
4154
- self.$searchContainer.removeClass('select2-search--hide');
4255
+ self.$searchContainer[0].classList.remove('select2-search--hide');
4155
4256
  } else {
4156
- self.$searchContainer.addClass('select2-search--hide');
4257
+ self.$searchContainer[0].classList.add('select2-search--hide');
4157
4258
  }
4158
4259
  }
4159
4260
  });
@@ -4365,8 +4466,8 @@ S2.define('select2/dropdown/attachBody',[
4365
4466
  // Clone all of the container classes
4366
4467
  $dropdown.attr('class', $container.attr('class'));
4367
4468
 
4368
- $dropdown.removeClass('select2');
4369
- $dropdown.addClass('select2-container--open');
4469
+ $dropdown[0].classList.remove('select2');
4470
+ $dropdown[0].classList.add('select2-container--open');
4370
4471
 
4371
4472
  $dropdown.css({
4372
4473
  position: 'absolute',
@@ -4472,8 +4573,10 @@ S2.define('select2/dropdown/attachBody',[
4472
4573
  AttachBody.prototype._positionDropdown = function () {
4473
4574
  var $window = $(window);
4474
4575
 
4475
- var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
4476
- var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
4576
+ var isCurrentlyAbove = this.$dropdown[0].classList
4577
+ .contains('select2-dropdown--above');
4578
+ var isCurrentlyBelow = this.$dropdown[0].classList
4579
+ .contains('select2-dropdown--below');
4477
4580
 
4478
4581
  var newDirection = null;
4479
4582
 
@@ -4545,12 +4648,13 @@ S2.define('select2/dropdown/attachBody',[
4545
4648
  }
4546
4649
 
4547
4650
  if (newDirection != null) {
4548
- this.$dropdown
4549
- .removeClass('select2-dropdown--below select2-dropdown--above')
4550
- .addClass('select2-dropdown--' + newDirection);
4551
- this.$container
4552
- .removeClass('select2-container--below select2-container--above')
4553
- .addClass('select2-container--' + newDirection);
4651
+ this.$dropdown[0].classList.remove('select2-dropdown--below');
4652
+ this.$dropdown[0].classList.remove('select2-dropdown--above');
4653
+ this.$dropdown[0].classList.add('select2-dropdown--' + newDirection);
4654
+
4655
+ this.$container[0].classList.remove('select2-container--below');
4656
+ this.$container[0].classList.remove('select2-container--above');
4657
+ this.$container[0].classList.add('select2-container--' + newDirection);
4554
4658
  }
4555
4659
 
4556
4660
  this.$dropdownContainer.css(css);
@@ -4707,6 +4811,30 @@ S2.define('select2/dropdown/closeOnSelect',[
4707
4811
  return CloseOnSelect;
4708
4812
  });
4709
4813
 
4814
+ S2.define('select2/dropdown/dropdownCss',[
4815
+ '../utils'
4816
+ ], function (Utils) {
4817
+ function DropdownCSS () { }
4818
+
4819
+ DropdownCSS.prototype.render = function (decorated) {
4820
+ var $dropdown = decorated.call(this);
4821
+
4822
+ var dropdownCssClass = this.options.get('dropdownCssClass') || '';
4823
+
4824
+ if (dropdownCssClass.indexOf(':all:') !== -1) {
4825
+ dropdownCssClass = dropdownCssClass.replace(':all:', '');
4826
+
4827
+ Utils.copyNonInternalCssClasses($dropdown[0], this.$element[0]);
4828
+ }
4829
+
4830
+ $dropdown.addClass(dropdownCssClass);
4831
+
4832
+ return $dropdown;
4833
+ };
4834
+
4835
+ return DropdownCSS;
4836
+ });
4837
+
4710
4838
  S2.define('select2/i18n/en',[],function () {
4711
4839
  // English
4712
4840
  return {
@@ -4751,13 +4879,15 @@ S2.define('select2/i18n/en',[],function () {
4751
4879
  },
4752
4880
  removeAllItems: function () {
4753
4881
  return 'Remove all items';
4882
+ },
4883
+ removeItem: function () {
4884
+ return 'Remove item';
4754
4885
  }
4755
4886
  };
4756
4887
  });
4757
4888
 
4758
4889
  S2.define('select2/defaults',[
4759
4890
  'jquery',
4760
- 'require',
4761
4891
 
4762
4892
  './results',
4763
4893
 
@@ -4766,6 +4896,7 @@ S2.define('select2/defaults',[
4766
4896
  './selection/placeholder',
4767
4897
  './selection/allowClear',
4768
4898
  './selection/search',
4899
+ './selection/selectionCss',
4769
4900
  './selection/eventRelay',
4770
4901
 
4771
4902
  './utils',
@@ -4789,14 +4920,15 @@ S2.define('select2/defaults',[
4789
4920
  './dropdown/minimumResultsForSearch',
4790
4921
  './dropdown/selectOnClose',
4791
4922
  './dropdown/closeOnSelect',
4923
+ './dropdown/dropdownCss',
4792
4924
 
4793
4925
  './i18n/en'
4794
- ], function ($, require,
4926
+ ], function ($,
4795
4927
 
4796
4928
  ResultsList,
4797
4929
 
4798
4930
  SingleSelection, MultipleSelection, Placeholder, AllowClear,
4799
- SelectionSearch, EventRelay,
4931
+ SelectionSearch, SelectionCSS, EventRelay,
4800
4932
 
4801
4933
  Utils, Translation, DIACRITICS,
4802
4934
 
@@ -4805,6 +4937,7 @@ S2.define('select2/defaults',[
4805
4937
 
4806
4938
  Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
4807
4939
  AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
4940
+ DropdownCSS,
4808
4941
 
4809
4942
  EnglishTranslation) {
4810
4943
  function Defaults () {
@@ -4854,24 +4987,6 @@ S2.define('select2/defaults',[
4854
4987
  Tokenizer
4855
4988
  );
4856
4989
  }
4857
-
4858
- if (options.query != null) {
4859
- var Query = require(options.amdBase + 'compat/query');
4860
-
4861
- options.dataAdapter = Utils.Decorate(
4862
- options.dataAdapter,
4863
- Query
4864
- );
4865
- }
4866
-
4867
- if (options.initSelection != null) {
4868
- var InitSelection = require(options.amdBase + 'compat/initSelection');
4869
-
4870
- options.dataAdapter = Utils.Decorate(
4871
- options.dataAdapter,
4872
- InitSelection
4873
- );
4874
- }
4875
4990
  }
4876
4991
 
4877
4992
  if (options.resultsAdapter == null) {
@@ -4922,13 +5037,7 @@ S2.define('select2/defaults',[
4922
5037
  );
4923
5038
  }
4924
5039
 
4925
- if (
4926
- options.dropdownCssClass != null ||
4927
- options.dropdownCss != null ||
4928
- options.adaptDropdownCssClass != null
4929
- ) {
4930
- var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
4931
-
5040
+ if (options.dropdownCssClass != null) {
4932
5041
  options.dropdownAdapter = Utils.Decorate(
4933
5042
  options.dropdownAdapter,
4934
5043
  DropdownCSS
@@ -4970,16 +5079,10 @@ S2.define('select2/defaults',[
4970
5079
  );
4971
5080
  }
4972
5081
 
4973
- if (
4974
- options.containerCssClass != null ||
4975
- options.containerCss != null ||
4976
- options.adaptContainerCssClass != null
4977
- ) {
4978
- var ContainerCSS = require(options.amdBase + 'compat/containerCss');
4979
-
5082
+ if (options.selectionCssClass != null) {
4980
5083
  options.selectionAdapter = Utils.Decorate(
4981
5084
  options.selectionAdapter,
4982
- ContainerCSS
5085
+ SelectionCSS
4983
5086
  );
4984
5087
  }
4985
5088
 
@@ -5028,7 +5131,7 @@ S2.define('select2/defaults',[
5028
5131
 
5029
5132
  function matcher (params, data) {
5030
5133
  // Always return the object if there is nothing to compare
5031
- if ($.trim(params.term) === '') {
5134
+ if (params.term == null || params.term.trim() === '') {
5032
5135
  return data;
5033
5136
  }
5034
5137
 
@@ -5072,8 +5175,8 @@ S2.define('select2/defaults',[
5072
5175
  }
5073
5176
 
5074
5177
  this.defaults = {
5075
- amdBase: './',
5076
5178
  amdLanguageBase: './i18n/',
5179
+ autocomplete: 'off',
5077
5180
  closeOnSelect: true,
5078
5181
  debug: false,
5079
5182
  dropdownAutoWidth: false,
@@ -5133,7 +5236,7 @@ S2.define('select2/defaults',[
5133
5236
 
5134
5237
  var languages;
5135
5238
 
5136
- if (!$.isArray(language)) {
5239
+ if (!Array.isArray(language)) {
5137
5240
  languages = [language];
5138
5241
  } else {
5139
5242
  languages = language;
@@ -5214,11 +5317,10 @@ S2.define('select2/defaults',[
5214
5317
  });
5215
5318
 
5216
5319
  S2.define('select2/options',[
5217
- 'require',
5218
5320
  'jquery',
5219
5321
  './defaults',
5220
5322
  './utils'
5221
- ], function (require, $, Defaults, Utils) {
5323
+ ], function ($, Defaults, Utils) {
5222
5324
  function Options (options, $element) {
5223
5325
  this.options = options;
5224
5326
 
@@ -5231,15 +5333,6 @@ S2.define('select2/options',[
5231
5333
  }
5232
5334
 
5233
5335
  this.options = Defaults.apply(this.options);
5234
-
5235
- if ($element && $element.is('input')) {
5236
- var InputCompat = require(this.get('amdBase') + 'compat/inputData');
5237
-
5238
- this.options.dataAdapter = Utils.Decorate(
5239
- this.options.dataAdapter,
5240
- InputCompat
5241
- );
5242
- }
5243
5336
  }
5244
5337
 
5245
5338
  Options.prototype.fromElement = function ($e) {
@@ -5253,6 +5346,10 @@ S2.define('select2/options',[
5253
5346
  this.options.disabled = $e.prop('disabled');
5254
5347
  }
5255
5348
 
5349
+ if (this.options.autocomplete == null && $e.prop('autocomplete')) {
5350
+ this.options.autocomplete = $e.prop('autocomplete');
5351
+ }
5352
+
5256
5353
  if (this.options.dir == null) {
5257
5354
  if ($e.prop('dir')) {
5258
5355
  this.options.dir = $e.prop('dir');
@@ -5331,7 +5428,7 @@ S2.define('select2/options',[
5331
5428
  data = Utils._convertData(data);
5332
5429
 
5333
5430
  for (var key in data) {
5334
- if ($.inArray(key, excludedData) > -1) {
5431
+ if (excludedData.indexOf(key) > -1) {
5335
5432
  continue;
5336
5433
  }
5337
5434
 
@@ -5435,7 +5532,7 @@ S2.define('select2/core',[
5435
5532
  });
5436
5533
 
5437
5534
  // Hide the original select
5438
- $element.addClass('select2-hidden-accessible');
5535
+ $element[0].classList.add('select2-hidden-accessible');
5439
5536
  $element.attr('aria-hidden', 'true');
5440
5537
 
5441
5538
  // Synchronize any monitored attributes
@@ -5555,42 +5652,15 @@ S2.define('select2/core',[
5555
5652
  this._syncA = Utils.bind(this._syncAttributes, this);
5556
5653
  this._syncS = Utils.bind(this._syncSubtree, this);
5557
5654
 
5558
- if (this.$element[0].attachEvent) {
5559
- this.$element[0].attachEvent('onpropertychange', this._syncA);
5560
- }
5561
-
5562
- var observer = window.MutationObserver ||
5563
- window.WebKitMutationObserver ||
5564
- window.MozMutationObserver
5565
- ;
5566
-
5567
- if (observer != null) {
5568
- this._observer = new observer(function (mutations) {
5569
- self._syncA();
5570
- self._syncS(null, mutations);
5571
- });
5572
- this._observer.observe(this.$element[0], {
5573
- attributes: true,
5574
- childList: true,
5575
- subtree: false
5576
- });
5577
- } else if (this.$element[0].addEventListener) {
5578
- this.$element[0].addEventListener(
5579
- 'DOMAttrModified',
5580
- self._syncA,
5581
- false
5582
- );
5583
- this.$element[0].addEventListener(
5584
- 'DOMNodeInserted',
5585
- self._syncS,
5586
- false
5587
- );
5588
- this.$element[0].addEventListener(
5589
- 'DOMNodeRemoved',
5590
- self._syncS,
5591
- false
5592
- );
5593
- }
5655
+ this._observer = new window.MutationObserver(function (mutations) {
5656
+ self._syncA();
5657
+ self._syncS(mutations);
5658
+ });
5659
+ this._observer.observe(this.$element[0], {
5660
+ attributes: true,
5661
+ childList: true,
5662
+ subtree: false
5663
+ });
5594
5664
  };
5595
5665
 
5596
5666
  Select2.prototype._registerDataEvents = function () {
@@ -5614,7 +5684,7 @@ S2.define('select2/core',[
5614
5684
  });
5615
5685
 
5616
5686
  this.selection.on('*', function (name, params) {
5617
- if ($.inArray(name, nonRelayEvents) !== -1) {
5687
+ if (nonRelayEvents.indexOf(name) !== -1) {
5618
5688
  return;
5619
5689
  }
5620
5690
 
@@ -5642,23 +5712,23 @@ S2.define('select2/core',[
5642
5712
  var self = this;
5643
5713
 
5644
5714
  this.on('open', function () {
5645
- self.$container.addClass('select2-container--open');
5715
+ self.$container[0].classList.add('select2-container--open');
5646
5716
  });
5647
5717
 
5648
5718
  this.on('close', function () {
5649
- self.$container.removeClass('select2-container--open');
5719
+ self.$container[0].classList.remove('select2-container--open');
5650
5720
  });
5651
5721
 
5652
5722
  this.on('enable', function () {
5653
- self.$container.removeClass('select2-container--disabled');
5723
+ self.$container[0].classList.remove('select2-container--disabled');
5654
5724
  });
5655
5725
 
5656
5726
  this.on('disable', function () {
5657
- self.$container.addClass('select2-container--disabled');
5727
+ self.$container[0].classList.add('select2-container--disabled');
5658
5728
  });
5659
5729
 
5660
5730
  this.on('blur', function () {
5661
- self.$container.removeClass('select2-container--focus');
5731
+ self.$container[0].classList.remove('select2-container--focus');
5662
5732
  });
5663
5733
 
5664
5734
  this.on('query', function (params) {
@@ -5734,49 +5804,30 @@ S2.define('select2/core',[
5734
5804
  }
5735
5805
  };
5736
5806
 
5737
- Select2.prototype._isChangeMutation = function (evt, mutations) {
5738
- var changed = false;
5807
+ Select2.prototype._isChangeMutation = function (mutations) {
5739
5808
  var self = this;
5740
5809
 
5741
- // Ignore any mutation events raised for elements that aren't options or
5742
- // optgroups. This handles the case when the select element is destroyed
5743
- if (
5744
- evt && evt.target && (
5745
- evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
5746
- )
5747
- ) {
5748
- return;
5749
- }
5750
-
5751
- if (!mutations) {
5752
- // If mutation events aren't supported, then we can only assume that the
5753
- // change affected the selections
5754
- changed = true;
5755
- } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
5810
+ if (mutations.addedNodes && mutations.addedNodes.length > 0) {
5756
5811
  for (var n = 0; n < mutations.addedNodes.length; n++) {
5757
5812
  var node = mutations.addedNodes[n];
5758
5813
 
5759
5814
  if (node.selected) {
5760
- changed = true;
5815
+ return true;
5761
5816
  }
5762
5817
  }
5763
5818
  } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
5764
- changed = true;
5765
- } else if ($.isArray(mutations)) {
5766
- $.each(mutations, function(evt, mutation) {
5767
- if (self._isChangeMutation(evt, mutation)) {
5768
- // We've found a change mutation.
5769
- // Let's escape from the loop and continue
5770
- changed = true;
5771
- return false;
5772
- }
5819
+ return true;
5820
+ } else if (Array.isArray(mutations)) {
5821
+ return mutations.some(function (mutation) {
5822
+ return self._isChangeMutation(mutation);
5773
5823
  });
5774
5824
  }
5775
- return changed;
5825
+
5826
+ return false;
5776
5827
  };
5777
5828
 
5778
- Select2.prototype._syncSubtree = function (evt, mutations) {
5779
- var changed = this._isChangeMutation(evt, mutations);
5829
+ Select2.prototype._syncSubtree = function (mutations) {
5830
+ var changed = this._isChangeMutation(mutations);
5780
5831
  var self = this;
5781
5832
 
5782
5833
  // Only re-pull the data if we think there is a change
@@ -5881,11 +5932,11 @@ S2.define('select2/core',[
5881
5932
  };
5882
5933
 
5883
5934
  Select2.prototype.isOpen = function () {
5884
- return this.$container.hasClass('select2-container--open');
5935
+ return this.$container[0].classList.contains('select2-container--open');
5885
5936
  };
5886
5937
 
5887
5938
  Select2.prototype.hasFocus = function () {
5888
- return this.$container.hasClass('select2-container--focus');
5939
+ return this.$container[0].classList.contains('select2-container--focus');
5889
5940
  };
5890
5941
 
5891
5942
  Select2.prototype.focus = function (data) {
@@ -5894,7 +5945,7 @@ S2.define('select2/core',[
5894
5945
  return;
5895
5946
  }
5896
5947
 
5897
- this.$container.addClass('select2-container--focus');
5948
+ this.$container[0].classList.add('select2-container--focus');
5898
5949
  this.trigger('focus', {});
5899
5950
  };
5900
5951
 
@@ -5948,8 +5999,8 @@ S2.define('select2/core',[
5948
5999
 
5949
6000
  var newVal = args[0];
5950
6001
 
5951
- if ($.isArray(newVal)) {
5952
- newVal = $.map(newVal, function (obj) {
6002
+ if (Array.isArray(newVal)) {
6003
+ newVal = newVal.map(function (obj) {
5953
6004
  return obj.toString();
5954
6005
  });
5955
6006
  }
@@ -5960,21 +6011,8 @@ S2.define('select2/core',[
5960
6011
  Select2.prototype.destroy = function () {
5961
6012
  this.$container.remove();
5962
6013
 
5963
- if (this.$element[0].detachEvent) {
5964
- this.$element[0].detachEvent('onpropertychange', this._syncA);
5965
- }
5966
-
5967
- if (this._observer != null) {
5968
- this._observer.disconnect();
5969
- this._observer = null;
5970
- } else if (this.$element[0].removeEventListener) {
5971
- this.$element[0]
5972
- .removeEventListener('DOMAttrModified', this._syncA, false);
5973
- this.$element[0]
5974
- .removeEventListener('DOMNodeInserted', this._syncS, false);
5975
- this.$element[0]
5976
- .removeEventListener('DOMNodeRemoved', this._syncS, false);
5977
- }
6014
+ this._observer.disconnect();
6015
+ this._observer = null;
5978
6016
 
5979
6017
  this._syncA = null;
5980
6018
  this._syncS = null;
@@ -5983,7 +6021,7 @@ S2.define('select2/core',[
5983
6021
  this.$element.attr('tabindex',
5984
6022
  Utils.GetData(this.$element[0], 'old-tabindex'));
5985
6023
 
5986
- this.$element.removeClass('select2-hidden-accessible');
6024
+ this.$element[0].classList.remove('select2-hidden-accessible');
5987
6025
  this.$element.attr('aria-hidden', 'false');
5988
6026
  Utils.RemoveData(this.$element[0]);
5989
6027
  this.$element.removeData('select2');
@@ -6011,7 +6049,8 @@ S2.define('select2/core',[
6011
6049
 
6012
6050
  this.$container = $container;
6013
6051
 
6014
- this.$container.addClass('select2-container--' + this.options.get('theme'));
6052
+ this.$container[0].classList
6053
+ .add('select2-container--' + this.options.get('theme'));
6015
6054
 
6016
6055
  Utils.StoreData($container[0], 'element', this.$element);
6017
6056
 
@@ -6021,406 +6060,6 @@ S2.define('select2/core',[
6021
6060
  return Select2;
6022
6061
  });
6023
6062
 
6024
- S2.define('select2/compat/utils',[
6025
- 'jquery'
6026
- ], function ($) {
6027
- function syncCssClasses ($dest, $src, adapter) {
6028
- var classes, replacements = [], adapted;
6029
-
6030
- classes = $.trim($dest.attr('class'));
6031
-
6032
- if (classes) {
6033
- classes = '' + classes; // for IE which returns object
6034
-
6035
- $(classes.split(/\s+/)).each(function () {
6036
- // Save all Select2 classes
6037
- if (this.indexOf('select2-') === 0) {
6038
- replacements.push(this);
6039
- }
6040
- });
6041
- }
6042
-
6043
- classes = $.trim($src.attr('class'));
6044
-
6045
- if (classes) {
6046
- classes = '' + classes; // for IE which returns object
6047
-
6048
- $(classes.split(/\s+/)).each(function () {
6049
- // Only adapt non-Select2 classes
6050
- if (this.indexOf('select2-') !== 0) {
6051
- adapted = adapter(this);
6052
-
6053
- if (adapted != null) {
6054
- replacements.push(adapted);
6055
- }
6056
- }
6057
- });
6058
- }
6059
-
6060
- $dest.attr('class', replacements.join(' '));
6061
- }
6062
-
6063
- return {
6064
- syncCssClasses: syncCssClasses
6065
- };
6066
- });
6067
-
6068
- S2.define('select2/compat/containerCss',[
6069
- 'jquery',
6070
- './utils'
6071
- ], function ($, CompatUtils) {
6072
- // No-op CSS adapter that discards all classes by default
6073
- function _containerAdapter (clazz) {
6074
- return null;
6075
- }
6076
-
6077
- function ContainerCSS () { }
6078
-
6079
- ContainerCSS.prototype.render = function (decorated) {
6080
- var $container = decorated.call(this);
6081
-
6082
- var containerCssClass = this.options.get('containerCssClass') || '';
6083
-
6084
- if ($.isFunction(containerCssClass)) {
6085
- containerCssClass = containerCssClass(this.$element);
6086
- }
6087
-
6088
- var containerCssAdapter = this.options.get('adaptContainerCssClass');
6089
- containerCssAdapter = containerCssAdapter || _containerAdapter;
6090
-
6091
- if (containerCssClass.indexOf(':all:') !== -1) {
6092
- containerCssClass = containerCssClass.replace(':all:', '');
6093
-
6094
- var _cssAdapter = containerCssAdapter;
6095
-
6096
- containerCssAdapter = function (clazz) {
6097
- var adapted = _cssAdapter(clazz);
6098
-
6099
- if (adapted != null) {
6100
- // Append the old one along with the adapted one
6101
- return adapted + ' ' + clazz;
6102
- }
6103
-
6104
- return clazz;
6105
- };
6106
- }
6107
-
6108
- var containerCss = this.options.get('containerCss') || {};
6109
-
6110
- if ($.isFunction(containerCss)) {
6111
- containerCss = containerCss(this.$element);
6112
- }
6113
-
6114
- CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter);
6115
-
6116
- $container.css(containerCss);
6117
- $container.addClass(containerCssClass);
6118
-
6119
- return $container;
6120
- };
6121
-
6122
- return ContainerCSS;
6123
- });
6124
-
6125
- S2.define('select2/compat/dropdownCss',[
6126
- 'jquery',
6127
- './utils'
6128
- ], function ($, CompatUtils) {
6129
- // No-op CSS adapter that discards all classes by default
6130
- function _dropdownAdapter (clazz) {
6131
- return null;
6132
- }
6133
-
6134
- function DropdownCSS () { }
6135
-
6136
- DropdownCSS.prototype.render = function (decorated) {
6137
- var $dropdown = decorated.call(this);
6138
-
6139
- var dropdownCssClass = this.options.get('dropdownCssClass') || '';
6140
-
6141
- if ($.isFunction(dropdownCssClass)) {
6142
- dropdownCssClass = dropdownCssClass(this.$element);
6143
- }
6144
-
6145
- var dropdownCssAdapter = this.options.get('adaptDropdownCssClass');
6146
- dropdownCssAdapter = dropdownCssAdapter || _dropdownAdapter;
6147
-
6148
- if (dropdownCssClass.indexOf(':all:') !== -1) {
6149
- dropdownCssClass = dropdownCssClass.replace(':all:', '');
6150
-
6151
- var _cssAdapter = dropdownCssAdapter;
6152
-
6153
- dropdownCssAdapter = function (clazz) {
6154
- var adapted = _cssAdapter(clazz);
6155
-
6156
- if (adapted != null) {
6157
- // Append the old one along with the adapted one
6158
- return adapted + ' ' + clazz;
6159
- }
6160
-
6161
- return clazz;
6162
- };
6163
- }
6164
-
6165
- var dropdownCss = this.options.get('dropdownCss') || {};
6166
-
6167
- if ($.isFunction(dropdownCss)) {
6168
- dropdownCss = dropdownCss(this.$element);
6169
- }
6170
-
6171
- CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter);
6172
-
6173
- $dropdown.css(dropdownCss);
6174
- $dropdown.addClass(dropdownCssClass);
6175
-
6176
- return $dropdown;
6177
- };
6178
-
6179
- return DropdownCSS;
6180
- });
6181
-
6182
- S2.define('select2/compat/initSelection',[
6183
- 'jquery'
6184
- ], function ($) {
6185
- function InitSelection (decorated, $element, options) {
6186
- if (options.get('debug') && window.console && console.warn) {
6187
- console.warn(
6188
- 'Select2: The `initSelection` option has been deprecated in favor' +
6189
- ' of a custom data adapter that overrides the `current` method. ' +
6190
- 'This method is now called multiple times instead of a single ' +
6191
- 'time when the instance is initialized. Support will be removed ' +
6192
- 'for the `initSelection` option in future versions of Select2'
6193
- );
6194
- }
6195
-
6196
- this.initSelection = options.get('initSelection');
6197
- this._isInitialized = false;
6198
-
6199
- decorated.call(this, $element, options);
6200
- }
6201
-
6202
- InitSelection.prototype.current = function (decorated, callback) {
6203
- var self = this;
6204
-
6205
- if (this._isInitialized) {
6206
- decorated.call(this, callback);
6207
-
6208
- return;
6209
- }
6210
-
6211
- this.initSelection.call(null, this.$element, function (data) {
6212
- self._isInitialized = true;
6213
-
6214
- if (!$.isArray(data)) {
6215
- data = [data];
6216
- }
6217
-
6218
- callback(data);
6219
- });
6220
- };
6221
-
6222
- return InitSelection;
6223
- });
6224
-
6225
- S2.define('select2/compat/inputData',[
6226
- 'jquery',
6227
- '../utils'
6228
- ], function ($, Utils) {
6229
- function InputData (decorated, $element, options) {
6230
- this._currentData = [];
6231
- this._valueSeparator = options.get('valueSeparator') || ',';
6232
-
6233
- if ($element.prop('type') === 'hidden') {
6234
- if (options.get('debug') && console && console.warn) {
6235
- console.warn(
6236
- 'Select2: Using a hidden input with Select2 is no longer ' +
6237
- 'supported and may stop working in the future. It is recommended ' +
6238
- 'to use a `<select>` element instead.'
6239
- );
6240
- }
6241
- }
6242
-
6243
- decorated.call(this, $element, options);
6244
- }
6245
-
6246
- InputData.prototype.current = function (_, callback) {
6247
- function getSelected (data, selectedIds) {
6248
- var selected = [];
6249
-
6250
- if (data.selected || $.inArray(data.id, selectedIds) !== -1) {
6251
- data.selected = true;
6252
- selected.push(data);
6253
- } else {
6254
- data.selected = false;
6255
- }
6256
-
6257
- if (data.children) {
6258
- selected.push.apply(selected, getSelected(data.children, selectedIds));
6259
- }
6260
-
6261
- return selected;
6262
- }
6263
-
6264
- var selected = [];
6265
-
6266
- for (var d = 0; d < this._currentData.length; d++) {
6267
- var data = this._currentData[d];
6268
-
6269
- selected.push.apply(
6270
- selected,
6271
- getSelected(
6272
- data,
6273
- this.$element.val().split(
6274
- this._valueSeparator
6275
- )
6276
- )
6277
- );
6278
- }
6279
-
6280
- callback(selected);
6281
- };
6282
-
6283
- InputData.prototype.select = function (_, data) {
6284
- if (!this.options.get('multiple')) {
6285
- this.current(function (allData) {
6286
- $.map(allData, function (data) {
6287
- data.selected = false;
6288
- });
6289
- });
6290
-
6291
- this.$element.val(data.id);
6292
- this.$element.trigger('input').trigger('change');
6293
- } else {
6294
- var value = this.$element.val();
6295
- value += this._valueSeparator + data.id;
6296
-
6297
- this.$element.val(value);
6298
- this.$element.trigger('input').trigger('change');
6299
- }
6300
- };
6301
-
6302
- InputData.prototype.unselect = function (_, data) {
6303
- var self = this;
6304
-
6305
- data.selected = false;
6306
-
6307
- this.current(function (allData) {
6308
- var values = [];
6309
-
6310
- for (var d = 0; d < allData.length; d++) {
6311
- var item = allData[d];
6312
-
6313
- if (data.id == item.id) {
6314
- continue;
6315
- }
6316
-
6317
- values.push(item.id);
6318
- }
6319
-
6320
- self.$element.val(values.join(self._valueSeparator));
6321
- self.$element.trigger('input').trigger('change');
6322
- });
6323
- };
6324
-
6325
- InputData.prototype.query = function (_, params, callback) {
6326
- var results = [];
6327
-
6328
- for (var d = 0; d < this._currentData.length; d++) {
6329
- var data = this._currentData[d];
6330
-
6331
- var matches = this.matches(params, data);
6332
-
6333
- if (matches !== null) {
6334
- results.push(matches);
6335
- }
6336
- }
6337
-
6338
- callback({
6339
- results: results
6340
- });
6341
- };
6342
-
6343
- InputData.prototype.addOptions = function (_, $options) {
6344
- var options = $.map($options, function ($option) {
6345
- return Utils.GetData($option[0], 'data');
6346
- });
6347
-
6348
- this._currentData.push.apply(this._currentData, options);
6349
- };
6350
-
6351
- return InputData;
6352
- });
6353
-
6354
- S2.define('select2/compat/matcher',[
6355
- 'jquery'
6356
- ], function ($) {
6357
- function oldMatcher (matcher) {
6358
- function wrappedMatcher (params, data) {
6359
- var match = $.extend(true, {}, data);
6360
-
6361
- if (params.term == null || $.trim(params.term) === '') {
6362
- return match;
6363
- }
6364
-
6365
- if (data.children) {
6366
- for (var c = data.children.length - 1; c >= 0; c--) {
6367
- var child = data.children[c];
6368
-
6369
- // Check if the child object matches
6370
- // The old matcher returned a boolean true or false
6371
- var doesMatch = matcher(params.term, child.text, child);
6372
-
6373
- // If the child didn't match, pop it off
6374
- if (!doesMatch) {
6375
- match.children.splice(c, 1);
6376
- }
6377
- }
6378
-
6379
- if (match.children.length > 0) {
6380
- return match;
6381
- }
6382
- }
6383
-
6384
- if (matcher(params.term, data.text, data)) {
6385
- return match;
6386
- }
6387
-
6388
- return null;
6389
- }
6390
-
6391
- return wrappedMatcher;
6392
- }
6393
-
6394
- return oldMatcher;
6395
- });
6396
-
6397
- S2.define('select2/compat/query',[
6398
-
6399
- ], function () {
6400
- function Query (decorated, $element, options) {
6401
- if (options.get('debug') && window.console && console.warn) {
6402
- console.warn(
6403
- 'Select2: The `query` option has been deprecated in favor of a ' +
6404
- 'custom data adapter that overrides the `query` method. Support ' +
6405
- 'will be removed for the `query` option in future versions of ' +
6406
- 'Select2.'
6407
- );
6408
- }
6409
-
6410
- decorated.call(this, $element, options);
6411
- }
6412
-
6413
- Query.prototype.query = function (_, params, callback) {
6414
- params.callback = callback;
6415
-
6416
- var query = this.options.get('query');
6417
-
6418
- query.call(null, params);
6419
- };
6420
-
6421
- return Query;
6422
- });
6423
-
6424
6063
  S2.define('select2/dropdown/attachContainer',[
6425
6064
 
6426
6065
  ], function () {
@@ -6433,8 +6072,8 @@ S2.define('select2/dropdown/attachContainer',[
6433
6072
  var $dropdownContainer = $container.find('.dropdown-wrapper');
6434
6073
  $dropdownContainer.append($dropdown);
6435
6074
 
6436
- $dropdown.addClass('select2-dropdown--below');
6437
- $container.addClass('select2-container--below');
6075
+ $dropdown[0].classList.add('select2-dropdown--below');
6076
+ $container[0].classList.add('select2-container--below');
6438
6077
  };
6439
6078
 
6440
6079
  return AttachContainer;
@@ -6781,7 +6420,7 @@ S2.define('jquery.select2',[
6781
6420
  });
6782
6421
 
6783
6422
  // Check if we should be returning `this`
6784
- if ($.inArray(options, thisMethods) > -1) {
6423
+ if (thisMethods.indexOf(options) > -1) {
6785
6424
  return this;
6786
6425
  }
6787
6426