$.inArray now makes a === check because of IE.
$.inArray is used in $.fn.index, this is shorter, and breaks the loop when possible.
$.fn.index can receive a jquery object, and the first element is used
var ret = -1;
// Locate the position of the desired element
- this.each(function(i){
- if ( this == elem )
- ret = i;
- });
-
- return ret;
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem && elem.jquery ? elem[0] : elem
+ , this );
},
attr: function( name, value, type ) {
inArray: function( elem, array ) {
for ( var i = 0, length = array.length; i < length; i++ )
- if ( array[ i ] == elem )
+ // Use === because on IE, window == document
+ if ( array[ i ] === elem )
return i;
return -1;