Skip to main content

Bug Tracker

Side navigation

#7780 closed bug (worksforme)

Opened December 14, 2010 08:24PM UTC

Closed December 24, 2010 03:10PM UTC

Last modified June 05, 2011 07:05PM UTC

$.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:
Description

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

Attachments (0)
Change History (8)

Changed December 14, 2010 08:26PM UTC by rwaldron comment:1

component: unfiledcore
owner: → rwaldron
priority: undecidedhigh
status: newassigned

Initially reported by jaubourg here: #7743

Changed December 14, 2010 08:44PM UTC by rwaldron comment:2

Changed December 14, 2010 09:47PM UTC by rwaldron comment:3

keywords: → needsdocs
resolution: → wontfix
status: assignedclosed

Changed December 14, 2010 10:07PM UTC by rwaldron comment:4

resolution: wontfix
status: closedreopened

Changed December 24, 2010 02:34AM UTC by dmethvin comment:5

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?

Changed December 24, 2010 03:10PM UTC by rwaldron comment:6

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.

Changed April 20, 2011 07:43PM UTC by shane@grockit.com comment:7

	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;
	}

Changed June 05, 2011 07:05PM UTC by addyosmani comment:8

keywords: needsdocsneededdocs