aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2012-12-24 10:54:11 -0500
committerRick Waldron <waldron.rick@gmail.com>2012-12-26 13:34:38 -0500
commit3746bf8feb30bd875f736d57de6bd94abcbd53f5 (patch)
treea077eb5cee0fa40df006ac97cfa7a2f18b68243b
parent7e3f96cf3f2d6eb0a9328a4d0b195333077448fc (diff)
downloadjquery-3746bf8feb30bd875f736d57de6bd94abcbd53f5.tar.gz
jquery-3746bf8feb30bd875f736d57de6bd94abcbd53f5.zip
Explanations for each step of isPlainObject
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
-rw-r--r--src/core.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core.js b/src/core.js
index a89df3d4f..41e68268e 100644
--- a/src/core.js
+++ b/src/core.js
@@ -412,12 +412,17 @@ jQuery.extend({
},
isPlainObject: function( obj ) {
- // Not plain objects: params that are not [[Class]] "[object Object]", DOM nodes, window
+ // Not plain objects:
+ // - Any object or value whose internal [[Class]] property is not "[object Object]"
+ // - DOM nodes
+ // - window
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false;
}
// Support: Firefox >16
+ // The try/catch supresses exceptions thrown when attempting to access
+ // the "constructor" property of certain host objects, ie. |window.location|
try {
if ( obj.constructor &&
!core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
@@ -427,6 +432,8 @@ jQuery.extend({
return false;
}
+ // If the function hasn't returned already, we're confident that
+ // |obj| is a plain object, created by {} or constructed with new Object
return true;
},