aboutsummaryrefslogtreecommitdiffstats
path: root/src/core.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.js')
-rw-r--r--src/core.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core.js b/src/core.js
index 49c191b9c..c9b560ae3 100644
--- a/src/core.js
+++ b/src/core.js
@@ -704,16 +704,15 @@ jQuery.extend({
return ret;
},
- // arg is for internal usage only
+ // arg is for internal usage only
map: function( elems, callback, arg ) {
var value, ret = [],
- i = 0,
+ i = 0,
length = elems.length,
- // process .length if it's just an object member
- isArray = length !== undefined && ( elems[ length - 1 ] || jQuery.isArray( elems ) );
-
+ // jquery objects are treated as arrays
+ isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || jQuery.isArray( elems ) ) ;
+
// Go through the array, translating each of the items to their
- // new value (or values).
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg );
@@ -723,8 +722,8 @@ jQuery.extend({
}
}
- // Go thorugh every key on the object,
- } else {
+ // Go thorugh every key on the object,
+ } else {
for ( key in elems ) {
value = callback( elems[ key ], key, arg );