mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Explanations for each step of isPlainObject
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
parent
7e3f96cf3f
commit
3746bf8feb
@ -412,12 +412,17 @@ jQuery.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
isPlainObject: function( obj ) {
|
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 ) ) {
|
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support: Firefox >16
|
// Support: Firefox >16
|
||||||
|
// The try/catch supresses exceptions thrown when attempting to access
|
||||||
|
// the "constructor" property of certain host objects, ie. |window.location|
|
||||||
try {
|
try {
|
||||||
if ( obj.constructor &&
|
if ( obj.constructor &&
|
||||||
!core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
|
!core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
|
||||||
@ -427,6 +432,8 @@ jQuery.extend({
|
|||||||
return false;
|
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;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user