瀏覽代碼

Handle special characters in object ids

Slight performance hit as we are no longer using `qurySelectorAll`,
but it handles the situation a bit more cleanly and prevent future
issues with special characters.

This closes https://github.com/select2/select2/issues/3157.
Kevin Brown 10 年之前
父節點
當前提交
14279a012b
共有 5 個文件被更改,包括 9 次插入3 次删除
  1. 3 1
      dist/js/select2.full.js
  2. 0 0
      dist/js/select2.full.min.js
  3. 3 1
      dist/js/select2.js
  4. 0 0
      dist/js/select2.min.js
  5. 3 1
      src/js/select2/data/array.js

+ 3 - 1
dist/js/select2.full.js

@@ -3136,7 +3136,9 @@ S2.define('select2/data/array',[
   Utils.Extend(ArrayAdapter, SelectAdapter);
 
   ArrayAdapter.prototype.select = function (data) {
-    var $option = this.$element.find('option[value="' + data.id + '"]');
+    var $option = this.$element.find('option').filter(function (i, elm) {
+      return elm.value == data.id.toString();
+    });
 
     if ($option.length === 0) {
       $option = this.option(data);

File diff suppressed because it is too large
+ 0 - 0
dist/js/select2.full.min.js


+ 3 - 1
dist/js/select2.js

@@ -3136,7 +3136,9 @@ S2.define('select2/data/array',[
   Utils.Extend(ArrayAdapter, SelectAdapter);
 
   ArrayAdapter.prototype.select = function (data) {
-    var $option = this.$element.find('option[value="' + data.id + '"]');
+    var $option = this.$element.find('option').filter(function (i, elm) {
+      return elm.value == data.id.toString();
+    });
 
     if ($option.length === 0) {
       $option = this.option(data);

File diff suppressed because it is too large
+ 0 - 0
dist/js/select2.min.js


+ 3 - 1
src/js/select2/data/array.js

@@ -14,7 +14,9 @@ define([
   Utils.Extend(ArrayAdapter, SelectAdapter);
 
   ArrayAdapter.prototype.select = function (data) {
-    var $option = this.$element.find('option[value="' + data.id + '"]');
+    var $option = this.$element.find('option').filter(function (i, elm) {
+      return elm.value == data.id.toString();
+    });
 
     if ($option.length === 0) {
       $option = this.option(data);

Some files were not shown because too many files changed in this diff