Skip to main content

Bug Tracker

Side navigation

#4118 closed bug (invalid)

Opened February 11, 2009 01:33AM UTC

Closed February 11, 2009 03:06AM UTC

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 February 11, 2009 01:47AM UTC.

    screen shots of Firebug debug

Change History (1)

Changed February 11, 2009 03:06AM UTC by dmethvin comment:1

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");