Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#7780 closed bug (worksforme)

$.isPlainObject inconsistent

Reported by: rwaldron Owned by: rwaldron
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 5 years ago by rwaldron

  • Component changed from unfiled to core
  • Owner set to rwaldron
  • Priority changed from undecided to high
  • Status changed from new to assigned

Initially reported by jaubourg here: #7743

comment:3 Changed 5 years ago by rwaldron

  • Keywords needsdocs added
  • Resolution set to wontfix
  • Status changed from assigned to closed

comment:4 Changed 5 years ago by rwaldron

  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:5 Changed 5 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 5 years ago by rwaldron

  • Resolution set to worksforme
  • Status changed from reopened to closed

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 5 years ago by shane@…

	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 4 years ago by addyosmani

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