@@ -58,13 +58,13 @@ jQuery.fn = jQuery.prototype = {
58
58
// Get the Nth element in the matched element set OR
59
59
// Get the whole matched element set as a clean array
60
60
get : function ( num ) {
61
- return num = = null ?
61
+ return num ! = null ?
62
62
63
63
// Return a 'clean' array
64
- this . toArray ( ) :
64
+ ( num < 0 ? this [ num + this . length ] : this [ num ] ) :
65
65
66
66
// Return just the object
67
- ( num < 0 ? this [ this . length + num ] : this [ num ] ) ;
67
+ slice . call ( this ) ;
68
68
} ,
69
69
70
70
// Take an array of elements and push it onto the stack
@@ -89,6 +89,12 @@ jQuery.fn = jQuery.prototype = {
89
89
return jQuery . each ( this , callback , args ) ;
90
90
} ,
91
91
92
+ map : function ( callback ) {
93
+ return this . pushStack ( jQuery . map ( this , function ( elem , i ) {
94
+ return callback . call ( elem , i , elem ) ;
95
+ } ) ) ;
96
+ } ,
97
+
92
98
slice : function ( ) {
93
99
return this . pushStack ( slice . apply ( this , arguments ) ) ;
94
100
} ,
@@ -107,12 +113,6 @@ jQuery.fn = jQuery.prototype = {
107
113
return this . pushStack ( j >= 0 && j < len ? [ this [ j ] ] : [ ] ) ;
108
114
} ,
109
115
110
- map : function ( callback ) {
111
- return this . pushStack ( jQuery . map ( this , function ( elem , i ) {
112
- return callback . call ( elem , i , elem ) ;
113
- } ) ) ;
114
- } ,
115
-
116
116
end : function ( ) {
117
117
return this . prevObject || this . constructor ( null ) ;
118
118
} ,
@@ -134,9 +134,10 @@ jQuery.extend = jQuery.fn.extend = function() {
134
134
// Handle a deep copy situation
135
135
if ( typeof target === "boolean" ) {
136
136
deep = target ;
137
- target = arguments [ 1 ] || { } ;
137
+
138
138
// skip the boolean and the target
139
- i = 2 ;
139
+ target = arguments [ i ] || { } ;
140
+ i ++ ;
140
141
}
141
142
142
143
// Handle case when target is a string or something (possible in deep copy)
@@ -145,9 +146,9 @@ jQuery.extend = jQuery.fn.extend = function() {
145
146
}
146
147
147
148
// extend jQuery itself if only one argument is passed
148
- if ( length === i ) {
149
+ if ( i === length ) {
149
150
target = this ;
150
- -- i ;
151
+ i -- ;
151
152
}
152
153
153
154
for ( ; i < length ; i ++ ) {
@@ -195,6 +196,12 @@ jQuery.extend({
195
196
// Assume jQuery is ready without the ready module
196
197
isReady : true ,
197
198
199
+ error : function ( msg ) {
200
+ throw new Error ( msg ) ;
201
+ } ,
202
+
203
+ noop : function ( ) { } ,
204
+
198
205
noConflict : function ( deep ) {
199
206
if ( window . $ === jQuery ) {
200
207
window . $ = _$ ;
@@ -227,16 +234,6 @@ jQuery.extend({
227
234
return obj - parseFloat ( obj ) >= 0 ;
228
235
} ,
229
236
230
- type : function ( obj ) {
231
- if ( obj == null ) {
232
- return String ( obj ) ;
233
- }
234
- // Support: Android < 4.0, iOS < 6 (functionish RegExp)
235
- return typeof obj === "object" || typeof obj === "function" ?
236
- class2type [ toString . call ( obj ) ] || "object" :
237
- typeof obj ;
238
- } ,
239
-
240
237
isPlainObject : function ( obj ) {
241
238
// Not plain objects:
242
239
// - Any object or value whose internal [[Class]] property is not "[object Object]"
@@ -272,12 +269,16 @@ jQuery.extend({
272
269
return true ;
273
270
} ,
274
271
275
- error : function ( msg ) {
276
- throw new Error ( msg ) ;
272
+ type : function ( obj ) {
273
+ if ( obj == null ) {
274
+ return obj + "" ;
275
+ }
276
+ // Support: Android < 4.0, iOS < 6 (functionish RegExp)
277
+ return typeof obj === "object" || typeof obj === "function" ?
278
+ class2type [ toString . call ( obj ) ] || "object" :
279
+ typeof obj ;
277
280
} ,
278
281
279
- noop : function ( ) { } ,
280
-
281
282
// Evaluates a script in a global context
282
283
globalEval : function ( code ) {
283
284
var script ,
@@ -401,23 +402,23 @@ jQuery.extend({
401
402
return first ;
402
403
} ,
403
404
404
- grep : function ( elems , callback , inv ) {
405
- var retVal ,
406
- ret = [ ] ,
405
+ grep : function ( elems , callback , invert ) {
406
+ var callbackInverse ,
407
+ matches = [ ] ,
407
408
i = 0 ,
408
- length = elems . length ;
409
- inv = ! ! inv ;
409
+ length = elems . length ,
410
+ callbackExpect = ! invert ;
410
411
411
412
// Go through the array, only saving the items
412
413
// that pass the validator function
413
414
for ( ; i < length ; i ++ ) {
414
- retVal = ! ! callback ( elems [ i ] , i ) ;
415
- if ( inv !== retVal ) {
416
- ret . push ( elems [ i ] ) ;
415
+ callbackInverse = ! callback ( elems [ i ] , i ) ;
416
+ if ( callbackInverse !== callbackExpect ) {
417
+ matches . push ( elems [ i ] ) ;
417
418
}
418
419
}
419
420
420
- return ret ;
421
+ return matches ;
421
422
} ,
422
423
423
424
// arg is for internal usage only
@@ -434,7 +435,7 @@ jQuery.extend({
434
435
value = callback ( elems [ i ] , i , arg ) ;
435
436
436
437
if ( value != null ) {
437
- ret [ ret . length ] = value ;
438
+ ret . push ( value ) ;
438
439
}
439
440
}
440
441
@@ -444,7 +445,7 @@ jQuery.extend({
444
445
value = callback ( elems [ i ] , i , arg ) ;
445
446
446
447
if ( value != null ) {
447
- ret [ ret . length ] = value ;
448
+ ret . push ( value ) ;
448
449
}
449
450
}
450
451
}
@@ -501,17 +502,16 @@ function isArraylike( obj ) {
501
502
var length = obj . length ,
502
503
type = jQuery . type ( obj ) ;
503
504
504
- if ( jQuery . isWindow ( obj ) ) {
505
+ if ( type === "function" || jQuery . isWindow ( obj ) ) {
505
506
return false ;
506
507
}
507
508
508
509
if ( obj . nodeType === 1 && length ) {
509
510
return true ;
510
511
}
511
512
512
- return type === "array" || type !== "function" &&
513
- ( length === 0 ||
514
- typeof length === "number" && length > 0 && ( length - 1 ) in obj ) ;
513
+ return type === "array" || length === 0 ||
514
+ typeof length === "number" && length > 0 && ( length - 1 ) in obj ;
515
515
}
516
516
517
517
return jQuery ;
0 commit comments