mirror of
https://github.com/jquery/jquery.git
synced 2026-02-02 11:15:05 -05:00
Core: Standardize indexOf comparisons
not present: `< 0` present: `> -1` at index: `=== N` Closes gh-1984
This commit is contained in:
@@ -77,7 +77,7 @@ jQuery.fn.extend({
|
||||
j = 0;
|
||||
while ( (clazz = classes[j++]) ) {
|
||||
// Remove *all* instances
|
||||
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
|
||||
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
|
||||
cur = cur.replace( " " + clazz + " ", " " );
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ jQuery.fn.extend({
|
||||
l = this.length;
|
||||
for ( ; i < l; i++ ) {
|
||||
if ( this[i].nodeType === 1 &&
|
||||
(" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
||||
(" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ jQuery.extend({
|
||||
while ( i-- ) {
|
||||
option = options[ i ];
|
||||
if ( (option.selected =
|
||||
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0) ) {
|
||||
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1) ) {
|
||||
optionSet = true;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ jQuery.each([ "radio", "checkbox" ], function() {
|
||||
jQuery.valHooks[ this ] = {
|
||||
set: function( elem, value ) {
|
||||
if ( jQuery.isArray( value ) ) {
|
||||
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
|
||||
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) > -1 );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user