aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlrbabe <lrbabe@gmail.com>2009-11-11 15:15:58 -0500
committerJohn Resig <jeresig@gmail.com>2009-11-11 15:15:58 -0500
commitc07d15d5a26c5b5dc2af7b396a704784d5bede34 (patch)
treea5e1177ccad915aa4cff2186fcf2656d37b9af27 /src
parent5ac2e0837cd5c86acc526c5bc5c3abbe91303116 (diff)
downloadjquery-c07d15d5a26c5b5dc2af7b396a704784d5bede34.tar.gz
jquery-c07d15d5a26c5b5dc2af7b396a704784d5bede34.zip
Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe and Andrea for the patch. Fixes #5160.
Diffstat (limited to 'src')
-rw-r--r--src/core.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core.js b/src/core.js
index cdd78517f..611e5363b 100644
--- a/src/core.js
+++ b/src/core.js
@@ -441,6 +441,10 @@ jQuery.extend({
},
inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
for ( var i = 0, length = array.length; i < length; i++ ) {
if ( array[ i ] === elem ) {
return i;