X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=addff6bde760d48b93867cd265474229b22b54d6;hb=4b55e94d0849568a2fd121952f13a9d6571c731f;hp=ff31e813db0f06498a2274fa288949b05b3bd24b;hpb=ef05f44cce870a8b78637b0a88b27087f7f13b37;p=jquery.git diff --git a/src/core.js b/src/core.js index ff31e81..addff6b 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ) {