Core: Standardize indexOf comparisons

not present: `< 0`
present: `> -1`
at index: `=== N`

Closes gh-1984
This commit is contained in:
Richard Gibson
2014-12-31 18:31:27 -05:00
parent 4cbf02df84
commit 53aa87f3bf
8 changed files with 12 additions and 11 deletions

View File

@@ -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;
}

View File

@@ -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 );
}
}
};