1
0
mirror of synced 2024-11-22 13:06:08 +03:00

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.
This commit is contained in:
Kevin Brown 2015-03-18 10:56:10 -04:00
parent 1f62eb67e8
commit 14279a012b
5 changed files with 12 additions and 6 deletions

View File

@ -3136,7 +3136,9 @@ S2.define('select2/data/array',[
Utils.Extend(ArrayAdapter, SelectAdapter); Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) { 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) { if ($option.length === 0) {
$option = this.option(data); $option = this.option(data);

File diff suppressed because one or more lines are too long

4
dist/js/select2.js vendored
View File

@ -3136,7 +3136,9 @@ S2.define('select2/data/array',[
Utils.Extend(ArrayAdapter, SelectAdapter); Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) { 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) { if ($option.length === 0) {
$option = this.option(data); $option = this.option(data);

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,9 @@ define([
Utils.Extend(ArrayAdapter, SelectAdapter); Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) { 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) { if ($option.length === 0) {
$option = this.option(data); $option = this.option(data);