1
0
mirror of synced 2024-11-26 06:46:04 +03:00

replaced usages of [].indexOf with $.inArray()

X-Browser Compatibility (and performance) reasons.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
This commit is contained in:
th3byrdm4n 2015-02-14 13:37:18 -10:00 committed by Kevin Brown
parent e75cd78c51
commit 07c4db1de2
10 changed files with 29 additions and 29 deletions

View File

@ -352,7 +352,7 @@ define('select2/results',[
var item = $.data(this, 'data'); var item = $.data(this, 'data');
if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) { if ($.inArray(item.id, selectedIds) > -1) {
$option.attr('aria-selected', 'true'); $option.attr('aria-selected', 'true');
} else { } else {
$option.attr('aria-selected', 'false'); $option.attr('aria-selected', 'false');
@ -2394,7 +2394,7 @@ define('select2/data/select',[
for (var d = 0; d < data.length; d++) { for (var d = 0; d < data.length; d++) {
var id = data[d].id; var id = data[d].id;
if (val.indexOf(id) === -1) { if ($.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -2432,7 +2432,7 @@ define('select2/data/select',[
for (var d = 0; d < currentData.length; d++) { for (var d = 0; d < currentData.length; d++) {
var id = currentData[d].id; var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) { if (id !== data.id && $.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -2971,7 +2971,7 @@ define('select2/data/tokenizer',[
while (i < term.length) { while (i < term.length) {
var termChar = term[i]; var termChar = term[i];
if (separators.indexOf(termChar) === -1) { if ($.inArray(termChar, separators) === -1) {
i++; i++;
continue; continue;
@ -4121,7 +4121,7 @@ define('select2/options',[
data = Utils._convertData(data); data = Utils._convertData(data);
for (var key in data) { for (var key in data) {
if (excludedData.indexOf(key) > -1) { if ($.inArray(key, excludedData) > -1) {
continue; continue;
} }

View File

@ -352,7 +352,7 @@ define('select2/results',[
var item = $.data(this, 'data'); var item = $.data(this, 'data');
if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) { if ($.inArray(item.id, selectedIds) > -1) {
$option.attr('aria-selected', 'true'); $option.attr('aria-selected', 'true');
} else { } else {
$option.attr('aria-selected', 'false'); $option.attr('aria-selected', 'false');
@ -2394,7 +2394,7 @@ define('select2/data/select',[
for (var d = 0; d < data.length; d++) { for (var d = 0; d < data.length; d++) {
var id = data[d].id; var id = data[d].id;
if (val.indexOf(id) === -1) { if ($.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -2432,7 +2432,7 @@ define('select2/data/select',[
for (var d = 0; d < currentData.length; d++) { for (var d = 0; d < currentData.length; d++) {
var id = currentData[d].id; var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) { if (id !== data.id && $.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -2971,7 +2971,7 @@ define('select2/data/tokenizer',[
while (i < term.length) { while (i < term.length) {
var termChar = term[i]; var termChar = term[i];
if (separators.indexOf(termChar) === -1) { if ($.inArray(termChar, separators) === -1) {
i++; i++;
continue; continue;
@ -4121,7 +4121,7 @@ define('select2/options',[
data = Utils._convertData(data); data = Utils._convertData(data);
for (var key in data) { for (var key in data) {
if (excludedData.indexOf(key) > -1) { if ($.inArray(key, excludedData) > -1) {
continue; continue;
} }

View File

@ -791,7 +791,7 @@ define('select2/results',[
var item = $.data(this, 'data'); var item = $.data(this, 'data');
if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) { if ($.inArray(item.id, selectedIds) > -1) {
$option.attr('aria-selected', 'true'); $option.attr('aria-selected', 'true');
} else { } else {
$option.attr('aria-selected', 'false'); $option.attr('aria-selected', 'false');
@ -2833,7 +2833,7 @@ define('select2/data/select',[
for (var d = 0; d < data.length; d++) { for (var d = 0; d < data.length; d++) {
var id = data[d].id; var id = data[d].id;
if (val.indexOf(id) === -1) { if ($.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -2871,7 +2871,7 @@ define('select2/data/select',[
for (var d = 0; d < currentData.length; d++) { for (var d = 0; d < currentData.length; d++) {
var id = currentData[d].id; var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) { if (id !== data.id && $.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -3410,7 +3410,7 @@ define('select2/data/tokenizer',[
while (i < term.length) { while (i < term.length) {
var termChar = term[i]; var termChar = term[i];
if (separators.indexOf(termChar) === -1) { if ($.inArray(termChar, separators) === -1) {
i++; i++;
continue; continue;
@ -4560,7 +4560,7 @@ define('select2/options',[
data = Utils._convertData(data); data = Utils._convertData(data);
for (var key in data) { for (var key in data) {
if (excludedData.indexOf(key) > -1) { if ($.inArray(key, excludedData) > -1) {
continue; continue;
} }

File diff suppressed because one or more lines are too long

10
dist/js/select2.js vendored
View File

@ -791,7 +791,7 @@ define('select2/results',[
var item = $.data(this, 'data'); var item = $.data(this, 'data');
if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) { if ($.inArray(item.id, selectedIds) > -1) {
$option.attr('aria-selected', 'true'); $option.attr('aria-selected', 'true');
} else { } else {
$option.attr('aria-selected', 'false'); $option.attr('aria-selected', 'false');
@ -2833,7 +2833,7 @@ define('select2/data/select',[
for (var d = 0; d < data.length; d++) { for (var d = 0; d < data.length; d++) {
var id = data[d].id; var id = data[d].id;
if (val.indexOf(id) === -1) { if ($.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -2871,7 +2871,7 @@ define('select2/data/select',[
for (var d = 0; d < currentData.length; d++) { for (var d = 0; d < currentData.length; d++) {
var id = currentData[d].id; var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) { if (id !== data.id && $.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -3410,7 +3410,7 @@ define('select2/data/tokenizer',[
while (i < term.length) { while (i < term.length) {
var termChar = term[i]; var termChar = term[i];
if (separators.indexOf(termChar) === -1) { if ($.inArray(termChar, separators) === -1) {
i++; i++;
continue; continue;
@ -4560,7 +4560,7 @@ define('select2/options',[
data = Utils._convertData(data); data = Utils._convertData(data);
for (var key in data) { for (var key in data) {
if (excludedData.indexOf(key) > -1) { if ($.inArray(key, excludedData) > -1) {
continue; continue;
} }

File diff suppressed because one or more lines are too long

View File

@ -49,7 +49,7 @@ define([
for (var d = 0; d < data.length; d++) { for (var d = 0; d < data.length; d++) {
var id = data[d].id; var id = data[d].id;
if (val.indexOf(id) === -1) { if ($.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }
@ -87,7 +87,7 @@ define([
for (var d = 0; d < currentData.length; d++) { for (var d = 0; d < currentData.length; d++) {
var id = currentData[d].id; var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) { if (id !== data.id && $.inArray(id, val) === -1) {
val.push(id); val.push(id);
} }
} }

View File

@ -57,7 +57,7 @@ define([
while (i < term.length) { while (i < term.length) {
var termChar = term[i]; var termChar = term[i];
if (separators.indexOf(termChar) === -1) { if ($.inArray(termChar, separators) === -1) {
i++; i++;
continue; continue;

View File

@ -75,7 +75,7 @@ define([
data = Utils._convertData(data); data = Utils._convertData(data);
for (var key in data) { for (var key in data) {
if (excludedData.indexOf(key) > -1) { if ($.inArray(key, excludedData) > -1) {
continue; continue;
} }

View File

@ -106,7 +106,7 @@ define([
var item = $.data(this, 'data'); var item = $.data(this, 'data');
if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) { if ($.inArray(item.id, selectedIds) > -1) {
$option.attr('aria-selected', 'true'); $option.attr('aria-selected', 'true');
} else { } else {
$option.attr('aria-selected', 'false'); $option.attr('aria-selected', 'false');