Bug Tracker

Modify

Ticket #4118 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

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

Change History

Changed 4 years ago by jbeckton

screen shots of Firebug debug

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.