Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe and Andrea for the patch. Fixes #5160.
This commit is contained in:
parent
5ac2e0837c
commit
c07d15d5a2
|
@ -441,6 +441,10 @@ jQuery.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
inArray: function( elem, array ) {
|
inArray: function( elem, array ) {
|
||||||
|
if ( array.indexOf ) {
|
||||||
|
return array.indexOf( elem );
|
||||||
|
}
|
||||||
|
|
||||||
for ( var i = 0, length = array.length; i < length; i++ ) {
|
for ( var i = 0, length = array.length; i < length; i++ ) {
|
||||||
if ( array[ i ] === elem ) {
|
if ( array[ i ] === elem ) {
|
||||||
return i;
|
return i;
|
||||||
|
|
Loading…
Reference in a new issue