]> source.dussan.org Git - jquery.git/commitdiff
Core: Standardize indexOf comparisons
authorRichard Gibson <richard.gibson@gmail.com>
Wed, 31 Dec 2014 23:31:27 +0000 (18:31 -0500)
committerRichard Gibson <richard.gibson@gmail.com>
Sun, 11 Jan 2015 04:47:01 +0000 (23:47 -0500)
not present: `< 0`
present: `> -1`
at index: `=== N`

Closes gh-1984

src/ajax/jsonp.js
src/ajax/load.js
src/attributes/classes.js
src/attributes/val.js
src/data.js
src/event.js
src/manipulation.js
src/traversing/findFilter.js

index d7ca7e1a7f9c4368e14c4ac99f24b45c3fc43bf9..a04898f67def913a82fbd191db7ff191e798ba57 100644 (file)
@@ -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"
                );
 
index bff25b1a4043bb9e0279345aace2b95adab1708c..2d56b704b8821be192e8f626693d6d7e992ffa75 100644 (file)
@@ -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 );
        }
index c8d1393f0b422a93311a3f43baee924c812682b3..f9dba94f7de43d6b6b7256e05e0d17c4741a4cde 100644 (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;
                        }
index c5e8c63f42c17d16f888f9e34105ce66ec6f9c33..1bb9072e6cc53aba7c77ecad2c4a7a7ffaca60fe 100644 (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 );
                        }
                }
        };
index be80a1e38d42ad207cead3a0721cdcb754d1457f..f283a6d7077c82852cb6891379bd7737c2f28861 100644 (file)
@@ -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 );
                                }
                        });
index 11b2ea9048619df7eb9381149a80e32bcd773c24..f17a1de7790b844772381203164376cfe965e5b1 100644 (file)
@@ -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 ] ) {
index 52b83c71bb96e1247fadfb1e5f1ddbf1125b8f94..e66998d53e0789321f4a0da1a0dae33b920e085d 100644 (file)
@@ -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;
                        }
 
index dd70a73f77364d130d37437a3176c4eb1736df5f..840229bff51eb2ce9b637dae2e11381a7d189b73 100644 (file)
@@ -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;
        });
 }