aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2014-12-31 18:31:27 -0500
committerRichard Gibson <richard.gibson@gmail.com>2015-01-10 23:47:01 -0500
commit53aa87f3bf4284763405f3eb8affff296e55ba4f (patch)
treeaa6731b18465d87fbd0f1b93a33cdb1e59a5d04e /src
parent4cbf02df84dbcaa44b75a64ed832f7dbff2231dd (diff)
downloadjquery-53aa87f3bf4284763405f3eb8affff296e55ba4f.tar.gz
jquery-53aa87f3bf4284763405f3eb8affff296e55ba4f.zip
Core: Standardize indexOf comparisons
not present: `< 0` present: `> -1` at index: `=== N` Closes gh-1984
Diffstat (limited to 'src')
-rw-r--r--src/ajax/jsonp.js3
-rw-r--r--src/ajax/load.js2
-rw-r--r--src/attributes/classes.js4
-rw-r--r--src/attributes/val.js4
-rw-r--r--src/data.js2
-rw-r--r--src/event.js4
-rw-r--r--src/manipulation.js2
-rw-r--r--src/traversing/findFilter.js2
8 files changed, 12 insertions, 11 deletions
diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js
index d7ca7e1a7..a04898f67 100644
--- a/src/ajax/jsonp.js
+++ b/src/ajax/jsonp.js
@@ -25,7 +25,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" :
typeof s.data === "string" &&
- !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
+ ( s.contentType || "" )
+ .indexOf("application/x-www-form-urlencoded") === 0 &&
rjsonp.test( s.data ) && "data"
);
diff --git a/src/ajax/load.js b/src/ajax/load.js
index bff25b1a4..2d56b704b 100644
--- a/src/ajax/load.js
+++ b/src/ajax/load.js
@@ -24,7 +24,7 @@ jQuery.fn.load = function( url, params, callback ) {
self = this,
off = url.indexOf(" ");
- if ( off >= 0 ) {
+ if ( off > -1 ) {
selector = jQuery.trim( url.slice( off ) );
url = url.slice( 0, off );
}
diff --git a/src/attributes/classes.js b/src/attributes/classes.js
index c8d1393f0..f9dba94f7 100644
--- a/src/attributes/classes.js
+++ b/src/attributes/classes.js
@@ -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;
}
diff --git a/src/attributes/val.js b/src/attributes/val.js
index c5e8c63f4..1bb9072e6 100644
--- a/src/attributes/val.js
+++ b/src/attributes/val.js
@@ -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 );
}
}
};
diff --git a/src/data.js b/src/data.js
index be80a1e38..f283a6d70 100644
--- a/src/data.js
+++ b/src/data.js
@@ -160,7 +160,7 @@ jQuery.fn.extend({
// *... In the case of properties that might _actually_
// have dashes, we need to also store a copy of that
// unchanged property.
- if ( key.indexOf("-") !== -1 && data !== undefined ) {
+ if ( key.indexOf("-") > -1 && data !== undefined ) {
dataUser.set( this, key, value );
}
});
diff --git a/src/event.js b/src/event.js
index 11b2ea904..f17a1de77 100644
--- a/src/event.js
+++ b/src/event.js
@@ -240,7 +240,7 @@ jQuery.event = {
return;
}
- if ( type.indexOf(".") >= 0 ) {
+ if ( type.indexOf(".") > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split(".");
type = namespaces.shift();
@@ -438,7 +438,7 @@ jQuery.event = {
if ( matches[ sel ] === undefined ) {
matches[ sel ] = handleObj.needsContext ?
- jQuery( sel, this ).index( cur ) >= 0 :
+ jQuery( sel, this ).index( cur ) > -1 :
jQuery.find( sel, this, null, [ cur ] ).length;
}
if ( matches[ sel ] ) {
diff --git a/src/manipulation.js b/src/manipulation.js
index 52b83c71b..e66998d53 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -248,7 +248,7 @@ jQuery.extend({
// #4087 - If origin and destination elements are the same, and this is
// that element, do not do anything
- if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
+ if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
continue;
}
diff --git a/src/traversing/findFilter.js b/src/traversing/findFilter.js
index dd70a73f7..840229bff 100644
--- a/src/traversing/findFilter.js
+++ b/src/traversing/findFilter.js
@@ -33,7 +33,7 @@ function winnow( elements, qualifier, not ) {
}
return jQuery.grep( elements, function( elem ) {
- return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
+ return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
});
}