Bug Tracker

Opened 11 years ago

Closed 11 years ago

#4118 closed bug (invalid)

jQuery.merge() resulting length property is incorrect

Reported by: jbeckton Owned by:
Priority: major Milestone: 1.3.1
Component: unfiled Version: 1.3.1
Keywords: Cc:
Blocked by: Blocking:

Description

I am using merge to join two arrays of DOM objects together. The resulting array has all the items in it but the length property is not being updated.

  var formOne = jQuery("#form1 > input"); //returns 3 items
  var formTwo = jQuery("#form2 > input"); //returns 4 items
  
  var fields = jQuery.merge( formOne, formTwo );
 
  console.log(fields); // shows Object length = 3 but if 
                       //I inspect the array further I see 7 elements in the array.
  

Attachments (1)

jQueryMerge.gif (44.0 KB) - added by jbeckton 11 years ago.
screen shots of Firebug debug

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by jbeckton

Attachment: jQueryMerge.gif added

screen shots of Firebug debug

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

http://docs.jquery.com/Utilities/jQuery.merge#firstsecond

Merge expects its first argument to be a real Array, which will automagically maintain a correct length property. You could use this instead:

jQuery("#form1 > input").add("#form2 > input");
Note: See TracTickets for help on using tickets.