Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#7780 closed bug (worksforme)

$.isPlainObject inconsistent

Reported by: Rick Waldron Owned by: Rick Waldron
Priority: high Milestone: 1.6
Component: core Version: 1.4.4
Keywords: neededdocs Cc:
Blocked by: Blocking:


As documented in this fiddle, $.isPlainObject() is evaluating inconsistently across browsers.

Change History (8)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledcore
Owner: set to Rick Waldron
Priority: undecidedhigh
Status: newassigned

Initially reported by jaubourg here: #7743

comment:3 Changed 12 years ago by Rick Waldron

Keywords: needsdocs added
Resolution: wontfix
Status: assignedclosed

comment:4 Changed 12 years ago by Rick Waldron

Resolution: wontfix
Status: closedreopened

comment:5 Changed 12 years ago by dmethvin

I thought we accepted that host objects might break this way, kind of like how we don't support $.isFunction(window.alert). Or is the needsdocs here just to say we need to document that fact?

comment:6 Changed 12 years ago by Rick Waldron

Resolution: worksforme
Status: reopenedclosed

Dave, yes - there are too many host objects that have too many inconsistencies for the library to robustly feature detect (without adding garbage regular expressions) - the needsdocs tag is to document this.

comment:7 Changed 12 years ago by [email protected]

	isPlainObject: function( obj ) {
		// Must be an Object.
		// Because of IE, we also have to check the presence of the constructor property.
		// 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;

		// Not own constructor property must be Object
		if ( obj.constructor &&
			!hasOwn.call(obj, "constructor") &&
			!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
			return false;

		// 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 ) {
		  if(!hasOwn.call( obj, key )){
		    return false;

		return key === undefined;

comment:8 Changed 12 years ago by addyosmani

Keywords: neededdocs added; needsdocs removed
Note: See TracTickets for help on using tickets.