diff options
author | Robert Katic <robert.katic@gmail.com> | 2009-12-19 00:34:20 +0800 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-12-19 01:19:34 +0800 |
commit | 148fb7ba8e992dd70c64cdc6a1c6f643fd1ba160 (patch) | |
tree | 9bda00fc30184e1e35c6c07a1b0b9127bc9e8850 /src | |
parent | 27d65b59f96460987abb84dadc3a75dde8826b3a (diff) | |
download | jquery-148fb7ba8e992dd70c64cdc6a1c6f643fd1ba160.tar.gz jquery-148fb7ba8e992dd70c64cdc6a1c6f643fd1ba160.zip |
Made isPlainObject() supporting null, undefined, and window values on IE too. Also added some related tests. Fixes #5669.
Diffstat (limited to 'src')
-rw-r--r-- | src/core.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core.js b/src/core.js index 1edf98edc..bc48e5d47 100644 --- a/src/core.js +++ b/src/core.js @@ -425,19 +425,21 @@ jQuery.extend({ }, isPlainObject: function( obj ) { - if ( toString.call(obj) !== "[object Object]" || typeof obj.nodeType === "number" ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + if ( !obj || toString.call(obj) !== "[object Object]" || !("constructor" in obj) ) { return false; } - // not own constructor property must be Object + // Not own constructor property must be Object if ( obj.constructor && !hasOwnProperty.call(obj, "constructor") && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) { return false; } - //own properties are iterated firstly, - //so to speed up, we can test last one if it is own or not + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. var key; for ( key in obj ) {} |