Skip to content
Permalink
Browse files

Use the native Array indexOf method if it exists, for jQuery.inArray.

  • Loading branch information
jeresig committed Sep 8, 2009
1 parent 96dd06e commit 1e750a00e988b4738e4b47b923bd78dbaffa6fb8
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/core.js
@@ -40,7 +40,8 @@ var jQuery = function( selector, context ) {
// Save a reference to some core methods
toString = Object.prototype.toString,
push = Array.prototype.push,
slice = Array.prototype.slice;
slice = Array.prototype.slice,
indexOf = Array.prototype.indexOf;

jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
@@ -522,6 +523,12 @@ jQuery.extend({
}
});

if ( indexOf ) {
jQuery.inArray = function( elem, array ) {
return indexOf.call( array, elem );
};
}

// All jQuery objects should point back to these
rootjQuery = jQuery(document);

0 comments on commit 1e750a0

Please sign in to comment.
You can’t perform that action at this time.