Commit 338eaf61 authored by Rick Waldron's avatar Rick Waldron

2.0: Reduce isPlainObject

Signed-off-by: 's avatarRick Waldron <waldron.rick@gmail.com>
parent 71696393
...@@ -417,32 +417,22 @@ jQuery.extend({ ...@@ -417,32 +417,22 @@ jQuery.extend({
}, },
isPlainObject: function( obj ) { isPlainObject: function( obj ) {
// Must be an Object. // Not plain objects: params that are not [[Class]] "[object Object]", DOM nodes, window
// Because of IE, we also have to check the presence of the constructor property. if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false; return false;
} }
// Firefox 17+ will throw on host objects. ie window.location
try { try {
// Not own constructor property must be Object
if ( obj.constructor && if ( obj.constructor &&
!core_hasOwn.call(obj, "constructor") && !core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false; return false;
} }
} catch ( e ) { } catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false; return false;
} }
// Own properties are enumerated firstly, so to speed up, return obj === Object( obj );
// if last one is own, then all properties are own.
var key;
for ( key in obj ) {}
return key === undefined || core_hasOwn.call( obj, key );
}, },
isEmptyObject: function( obj ) { isEmptyObject: function( obj ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment