Opened 9 years ago
Closed 9 years ago
#14227 closed bug (duplicate)
$.isPlainObject improperly returns true for moment.js in 2.x
Reported by: | dcherman | Owned by: | Rick Waldron |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 2.0.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In the 2.x branch, $.isPlainObject() returns true for a moment instance ( http://momentjs.com/ ) where in 1.x it returns false ( which is expected )
Test Case: http://jsfiddle.net/N5UBJ/1/
Change History (5)
comment:1 Changed 9 years ago by
Owner: | set to Rick Waldron |
---|---|
Status: | new → assigned |
comment:2 Changed 9 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
comment:3 Changed 9 years ago by
If this is a wontfix, then does that mean we're intentionally allowing a difference in behavior between 1.x and 2.x?
comment:4 Changed 9 years ago by
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
comment:5 Changed 9 years ago by
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Duplicate of #13571.
Note: See
TracTickets for help on using
tickets.
This isn't a bug in jQuery 2.x, it's a bug in Moment that was allowed by jQuery 1.x. In the moment.js source, where moment.prototype is defined, it's the constructor is being paved over and never restored.
https://github.com/moment/moment/blob/05028e20e526b5f38dde3748833e98d7c8e846e8/moment.js#L1133-L1468
A reduced case:
This can be fixed by restoring the constructor:
Notice that even jQuery does this for its own prototype: https://github.com/jquery/jquery/blob/master/src/core.js#L76-L80
For more information, read through: http://bugs.jquery.com/ticket/13571 specifically: http://bugs.jquery.com/ticket/13571#comment:4