aboutsummaryrefslogtreecommitdiffstats
path: root/src/core.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2012-07-09 21:38:11 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-07-09 21:39:22 -0400
commit8f01b92b8fd85a66f2cba671f8b9ff6f7095c34b (patch)
tree6120b02292d65f3ac1248a7c82aae5fbbb505d7d /src/core.js
parentf30f7732e7775b6e417c4c22ced7adb2bf76bf89 (diff)
downloadjquery-8f01b92b8fd85a66f2cba671f8b9ff6f7095c34b.tar.gz
jquery-8f01b92b8fd85a66f2cba671f8b9ff6f7095c34b.zip
Follow the style guide, lose 72 bytes! Closes gh-840.
Diffstat (limited to 'src/core.js')
-rw-r--r--src/core.js52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/core.js b/src/core.js
index 6b0615009..01a3019e7 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1,4 +1,10 @@
var
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // The deferred used on DOM ready
+ readyList,
+
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
location = window.location,
@@ -24,12 +30,6 @@ var
return new jQuery.fn.init( selector, context, rootjQuery );
},
- // A central reference to the root jQuery(document)
- rootjQuery,
-
- // The deferred used on DOM ready
- readyList,
-
// Used for detecting and trimming whitespace
core_rnotwhite = /\S/,
core_rspace = /\s+/,
@@ -449,7 +449,8 @@ jQuery.extend({
},
isEmptyObject: function( obj ) {
- for ( var name in obj ) {
+ var name;
+ for ( name in obj ) {
return false;
}
return true;
@@ -560,7 +561,8 @@ jQuery.extend({
// args is for internal usage only
each: function( obj, callback, args ) {
- var name, i = 0,
+ var name,
+ i = 0,
length = obj.length,
isObj = length === undefined || jQuery.isFunction( obj );
@@ -616,12 +618,13 @@ jQuery.extend({
// results is for internal usage only
makeArray: function( arr, results ) {
- var ret = results || [];
+ var type,
+ ret = results || [];
if ( arr != null ) {
// The window, strings (and functions) also have 'length'
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
- var type = jQuery.type( arr );
+ type = jQuery.type( arr );
if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
core_push.call( ret, arr );
@@ -656,11 +659,12 @@ jQuery.extend({
},
merge: function( first, second ) {
- var i = first.length,
+ var l = second.length,
+ i = first.length,
j = 0;
- if ( typeof second.length === "number" ) {
- for ( var l = second.length; j < l; j++ ) {
+ if ( typeof l === "number" ) {
+ for ( ; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
@@ -676,12 +680,15 @@ jQuery.extend({
},
grep: function( elems, callback, inv ) {
- var ret = [], retVal;
+ var retVal,
+ ret = [],
+ i = 0,
+ length = elems.length;
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++ ) {
+ for ( ; i < length; i++ ) {
retVal = !!callback( elems[ i ], i );
if ( inv !== retVal ) {
ret.push( elems[ i ] );
@@ -693,7 +700,8 @@ jQuery.extend({
// arg is for internal usage only
map: function( elems, callback, arg ) {
- var value, key, ret = [],
+ var value, key,
+ ret = [],
i = 0,
length = elems.length,
// jquery objects are treated as arrays
@@ -730,8 +738,10 @@ jQuery.extend({
// Bind a function to a context, optionally partially applying any
// arguments.
proxy: function( fn, context ) {
+ var tmp, args, proxy;
+
if ( typeof context === "string" ) {
- var tmp = fn[ context ];
+ tmp = fn[ context ];
context = fn;
fn = tmp;
}
@@ -743,10 +753,10 @@ jQuery.extend({
}
// Simulated bind
- var args = core_slice.call( arguments, 2 ),
- proxy = function() {
- return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
- };
+ args = core_slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
+ };
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;