-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Core: Allow more than 2 arrays for merge function. #1556
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
firstLen = first.length; | ||
|
||
for ( ; i < arguments.length ; i++ ) { | ||
// Only deal with non-null/undefined values |
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.
before als non-null/undefined values were copied
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.
non-null params?
$.merge([1, 2], null);
null as values are still copied:
$.merge([1, 2], [null]);
-> [1,2,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 right... your are skipping the arguments passed to the function not the values of the array...
Have you already opened a jquery ticket on the bugtracker for this request? Usually they decide which feature will be integrated their before actually implementing it. |
no, implementation was simple so i decided to implement it a try pull request it. should i open ticked for it now? |
yes, ticket is a must have. |
@onovy What is the use case for this? In general our utility functions should be kept as simple as possible and address the internal needs of the jQuery library. More complex needs can be addressed through a plugin. Would adding this feature allow us to simplify jQuery itself? If so can you identify the places where that would happen? |
I think utility from jQuery is not only for jQuery core, but for jQuery users too. New pattern simplifies usage, because it's same as extend, which many users expects. Of course it's usable in jQuery Core. |
We don't generally add features prospectively, without a use case that shows some benefit for more users or for our internal needs. That it is theoretically usable in core is not the same as showing places where we could benefit from multi-array Most users with a real |
general use case is same as .extend, where is difference? if most users uses Array#concat, why there is .merge in jQuery? Because it alters first array and don't create new array. Exactly same as .extend, but for Arrays and not Plain Objects. |
I don't see any significant benefit to adding this, but am still open to doing so if it could be used to good advantage in jQuery's code base. |
Closed, plugin. |
Function merge now allows only 2 arrays for merging. This patch allow to have more than 2 arrays for merging, same as function extend allows more then 2 plain objects for merge.
http://bugs.jquery.com/ticket/14982