mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
jquery core: closes #2771
$.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
This commit is contained in:
parent
ca73ba5668
commit
858d56fc8e
13
src/core.js
13
src/core.js
@ -140,12 +140,10 @@ jQuery.fn = jQuery.prototype = {
|
|||||||
var ret = -1;
|
var ret = -1;
|
||||||
|
|
||||||
// Locate the position of the desired element
|
// Locate the position of the desired element
|
||||||
this.each(function(i){
|
return jQuery.inArray(
|
||||||
if ( this == elem )
|
// If it receives a jQuery object, the first element is used
|
||||||
ret = i;
|
elem && elem.jquery ? elem[0] : elem
|
||||||
});
|
, this );
|
||||||
|
|
||||||
return ret;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
attr: function( name, value, type ) {
|
attr: function( name, value, type ) {
|
||||||
@ -1124,7 +1122,8 @@ jQuery.extend({
|
|||||||
|
|
||||||
inArray: function( elem, array ) {
|
inArray: function( elem, array ) {
|
||||||
for ( var i = 0, length = array.length; i < length; i++ )
|
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 i;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user