-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Core: .each should accept an undefined value
#2363
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
|
Thank you for opening a PR. We've discussed this issue here. It also affects |
|
Such a change requires a test, though. |
|
Oh right, cool, I will do this (the other PR and the test), this evening. |
|
I added a test, but this test fail actually, because modifying |
test/unit/core.js
Outdated
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.
If this PR should fix #2267 you probably should add tests for all those values
|
One PR is preferable, but we could do two atomic commits, one would ref, other would close |
|
Sorry, I should have suggested one PR.
|
|
So, I closed the other PR about |
src/core.js
Outdated
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.
Here the code return false for: null, undefined, "number", NaN, "function", "window" only.
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.
This is very hard to read. Please assign type in its declaration, and remove the type === "number" check completely. Also, it may be smaller to assign length in its declaration as well (e.g., length = obj != null && "length" in obj && obj.length).
|
This PR needs a reference to #2267 and unit tests for passing |
|
@gibson042, yeah I know I did it yesterday but markelog spoke about two atomic commits. |
|
Just add relevant commits for both |
|
@gibson042 all is done :) |
|
@mzgol, right, it's done :) |
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.
You mention Function here but the test is only about undefined/null.
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.
Oh it's because I am testing :
$.each( null || undefined, function() {
});Like the title of the precedent test ( jQuery.each(Object,Function) )
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.
Ah, it's a comma, not a slash. OK, sorry. :)
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.
This landed and nobody noticed that it should have used expect( 1 ) instead of the deprecated argument =/
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.
Oh the humanity! How can we possible recover from this horrible-horrible mistake?!
...
Sorry, couldn't resist.
We will fix all of that occurrences at some point.
|
LGTM now. |
|
Landed, thanks! |
Hi :)
I found in JS we have this:
And with the actual jQuery, sometime we have to do this:
If we reorder few instructions in the
$.eachfunction we can remove the necessity of theifabove.Do you agree?
EDIT (by @mzgol): Fixes gh-2267