diff options
author | lrbabe <lrbabe@gmail.com> | 2009-11-11 15:15:58 -0500 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-11-11 15:15:58 -0500 |
commit | c07d15d5a26c5b5dc2af7b396a704784d5bede34 (patch) | |
tree | a5e1177ccad915aa4cff2186fcf2656d37b9af27 /src | |
parent | 5ac2e0837cd5c86acc526c5bc5c3abbe91303116 (diff) | |
download | jquery-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.js | 4 |
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; |