From 1e750a00e988b4738e4b47b923bd78dbaffa6fb8 Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 8 Sep 2009 01:45:11 +0000 Subject: [PATCH] Use the native Array indexOf method if it exists, for jQuery.inArray. --- src/core.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 655325847..a7cbdc99c 100644 --- a/src/core.js +++ b/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);