Side navigation
#3914 closed bug (worksforme)
Opened January 19, 2009 03:28PM UTC
Closed May 09, 2009 04:20PM UTC
$.merge
Reported by: | pcicman | Owned by: | aflesler |
---|---|---|---|
Priority: | major | Milestone: | 1.3.1 |
Component: | core | Version: | 1.3 |
Keywords: | array merge | Cc: | |
Blocked by: | Blocking: |
Description
Doesn't work properly in 1.2.6:
var args = [1, 2, 3];
var appendArgs = ["A", false, 10];
$.merge(args, appendArgs);
should return:
[1, 2, 3, "A", false, 10]
returns:
[1, 2, 3, "A"]
This will probably not work in 1.3:
var args = [1, 2, 3];
var appendArgs = ["A", false, null, 10];
$.merge(args, appendArgs);
should return:
[1, 2, 3, "A", false, null, 10]
will probably return:
[1, 2, 3, "A", false]
Shouldn't it be better to use for loop instead while for merge function? Btw, array with null inside is still valid array.
Attachments (0)
Change History (4)
Changed January 22, 2009 02:55AM UTC by comment:1
owner: | → aflesler |
---|
Changed February 11, 2009 01:17AM UTC by comment:2
I am seeing some problems with jQuery.merge() as well. I am using jQuery 1.3.1 and i use the merge() function to merge arrays of DOM objects. I am getting all the objects in the final result but the array length still reflects the original value prior to the merge.
Changed February 13, 2009 02:35AM UTC by comment:3
jbeckton, are they really Javascript Array objects, or are they some sort of nodelist collection? The arguments to merge should be genuine arrays.
Changed May 09, 2009 04:20PM UTC by comment:4
resolution: | → worksforme |
---|---|
status: | new → closed |
I think
jQuery.mergeis working as documented so I'll close this.
jQuery.merge was mainly intended to merge arrays of DOM objects, although I agree the docs don't put any limits on what can be merged. The easiest "fix" might be to change the documentation. If you're really trying to combine two arrays, just use Array.concat.