More changes to get jQuery in line with JSLint.
[jquery.git] / src / core.js
index 9fa311d..50e1676 100644 (file)
@@ -18,7 +18,7 @@ var jQuery = function( selector, context ) {
 
        // A simple way to check for HTML strings or ID strings
        // (both of which we optimize for)
-       quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+       quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w\-]+)$/,
 
        // Is it a simple selector
        isSimple = /^.[^:#\[\.,]*$/,
@@ -49,7 +49,7 @@ var jQuery = function( selector, context ) {
 
        // Save a reference to some core methods
        toString = Object.prototype.toString,
-       hasOwnProperty = Object.prototype.hasOwnProperty,
+       hasOwn = Object.prototype.hasOwnProperty,
        push = Array.prototype.push,
        slice = Array.prototype.slice,
        indexOf = Array.prototype.indexOf;
@@ -450,9 +450,9 @@ jQuery.extend({
                }
                
                // Not own constructor property must be Object
-               if ( obj.constructor
-                       && !hasOwnProperty.call(obj, "constructor")
-                       && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+               if ( obj.constructor &&
+                       !hasOwn.call(obj, "constructor") &&
+                       !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
                        return false;
                }
                
@@ -462,7 +462,7 @@ jQuery.extend({
                var key;
                for ( key in obj ) {}
                
-               return key === undefined || hasOwnProperty.call( obj, key );
+               return key === undefined || hasOwn.call( obj, key );
        },
 
        isEmptyObject: function( obj ) {
@@ -623,12 +623,14 @@ jQuery.extend({
        },
 
        grep: function( elems, callback, inv ) {
-               var ret = [];
+               var ret = [], retVal;
+               inv = !!inv;
 
                // Go through the array, only saving the items
                // that pass the validator function
                for ( var i = 0, length = elems.length; i < length; i++ ) {
-                       if ( !inv !== !callback( elems[ i ], i ) ) {
+                       retVal = !!callback( elems[ i ], i );
+                       if ( inv !== retVal ) {
                                ret.push( elems[ i ] );
                        }
                }
@@ -693,7 +695,7 @@ jQuery.extend({
                        /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
                        /(msie) ([\w.]+)/.exec( ua ) ||
                        !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
-                       [];
+                       [];
 
                return { browser: match[1] || "", version: match[2] || "0" };
        },
@@ -748,7 +750,7 @@ function doScrollCheck() {
                // If IE is used, use the trick by Diego Perini
                // http://javascript.nwbox.com/IEContentLoaded/
                document.documentElement.doScroll("left");
-       } catch( error ) {
+       } catch(e) {
                setTimeout( doScrollCheck, 1 );
                return;
        }
@@ -799,9 +801,9 @@ function access( elems, key, value, exec, fn, pass ) {
        }
        
        // Getting an attribute
-       return length ? fn( elems[0], key ) : null;
+       return length ? fn( elems[0], key ) : undefined;
 }
 
 function now() {
-       return (new Date).getTime();
+       return (new Date()).getTime();
 }