Renamed isObject to isObjectLiteral to be more specific.
[jquery.git] / src / core.js
index f605e1d..addff6b 100644 (file)
@@ -39,6 +39,7 @@ var jQuery = function( selector, context ) {
 
        // Save a reference to some core methods
        toString = Object.prototype.toString,
+       hasOwnProperty = Object.prototype.hasOwnProperty,
        push = Array.prototype.push,
        slice = Array.prototype.slice,
        indexOf = Array.prototype.indexOf;
@@ -279,7 +280,7 @@ jQuery.extend = jQuery.fn.extend = function() {
                                                clone = src;
                                        } else if ( jQuery.isArray(copy) ) {
                                                clone = [];
-                                       } else if ( jQuery.isObject(copy) ) {
+                                       } else if ( jQuery.isObjectLiteral(copy) ) {
                                                clone = {};
                                        } else {
                                                clone = copy;
@@ -322,8 +323,18 @@ jQuery.extend({
                return toString.call(obj) === "[object Array]";
        },
 
-       isObject: function( obj ) {
-               return this.constructor.call(obj) === Object;
+       isObjectLiteral: function( obj ) {
+               if ( toString.call(obj) !== "[object Object]" ) {
+                       return false;
+               }
+               
+               //own properties are iterated firstly,
+               //so to speed up, we can test last one if it is own or not
+               
+               var key;
+               for ( key in obj ) {}
+               
+               return !key || hasOwnProperty.call( obj, key );
        },
 
        isEmptyObject: function( obj ) {
@@ -444,19 +455,8 @@ jQuery.extend({
                // expando of getElementsByTagName
                var i = 0, elem, pos = first.length;
 
-               // Also, we need to make sure that the correct elements are being returned
-               // (IE returns comment nodes in a '*' query)
-               if ( !jQuery.support.getAll ) {
-                       while ( (elem = second[ i++ ]) != null ) {
-                               if ( elem.nodeType !== 8 ) {
-                                       first[ pos++ ] = elem;
-                               }
-                       }
-
-               } else {
-                       while ( (elem = second[ i++ ]) != null ) {
-                               first[ pos++ ] = elem;
-                       }
+               while ( (elem = second[ i++ ]) != null ) {
+                       first[ pos++ ] = elem;
                }
 
                return first;