Core: .each should accept an undefined value#2363
Core: .each should accept an undefined value#2363mr21 wants to merge 3 commits intojquery:masterfrom
undefined value#2363Conversation
|
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Here the code return false for: null, undefined, "number", NaN, "function", "window" only.
There was a problem hiding this comment.
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.
You mention Function here but the test is only about undefined/null.
There was a problem hiding this comment.
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.
Ah, it's a comma, not a slash. OK, sorry. :)
There was a problem hiding this comment.
This landed and nobody noticed that it should have used expect( 1 ) instead of the deprecated argument =/
There was a problem hiding this comment.
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