Opened 14 years ago
Closed 14 years ago
#3914 closed bug (worksforme)
$.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.
Change History (4)
comment:1 Changed 14 years ago by
Owner: | set to aflesler |
---|
comment:2 Changed 14 years ago by
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.
comment:3 Changed 14 years ago by
jbeckton, are they really Javascript Array objects, or are they some sort of nodelist collection? The arguments to merge should be genuine arrays.
comment:4 Changed 14 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I think jQuery.merge
is 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.