-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Core: restore enumeration behavior in isPlainObject #2970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
test/unit/core.js
Outdated
|
|
||
| // The use case that we want to match | ||
| assert.ok( jQuery.isPlainObject( {} ), "{}" ); | ||
| assert.ok( jQuery.isPlainObject( new Object() ), "new Object" ); // jshint ignore:line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why jshint comment there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of new Object(), I guess. Is that test necessary considering that it's equivalent to {} if one doesn't modify Object.prototype which we don't support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new window.Object? If we talking about the same thing? jshint ignore:line is bit radical, it seems we should disable the rule, not the whole thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that new window.Object() does work! Didn't even know why would jshint highlight that - just pointed in the sky and made it rain i guess :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which a jshint bug of course :)
|
It seems |
| // |obj| is a plain object, created by {} or constructed with new Object | ||
| return true; | ||
| // Own properties are enumerated firstly, so to speed up, | ||
| // if last one is own, then all properties are own |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's clever!
Nice |
Ref 00575d4 Also see discussion in #2970 (comment)
Fixes gh-2968