#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: |
Description
As documented in this fiddle, $.isPlainObject() is evaluating inconsistently across browsers.
Change History (8)
comment:1 Changed 12 years ago by
Component: | unfiled → core |
---|---|
Owner: | set to Rick Waldron |
Priority: | undecided → high |
Status: | new → assigned |
comment:3 Changed 12 years ago by
Keywords: | needsdocs added |
---|---|
Resolution: | → wontfix |
Status: | assigned → closed |
comment:4 Changed 12 years ago by
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
comment:5 Changed 12 years ago by
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
Resolution: | → worksforme |
---|---|
Status: | reopened → 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 12 years ago by
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
Keywords: | neededdocs added; needsdocs removed |
---|
Documentation updated: http://api.jquery.com/jQuery.isPlainObject/
Note: See
TracTickets for help on using
tickets.
Initially reported by jaubourg here: #7743