Bug Tracker

Opened 7 years ago

Closed 7 years ago

#14000 closed bug (notabug)

jQuery.merge does not consider the nodelist

Reported by: goodluckyibiyihua@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.2
Keywords: Cc:
Blocked by: Blocking:

Description

var list1 = document.querySelectorAll(".lists1 li"); //list1.length = 20
var list2 = $(".lists2 li"); //list2.length = 20
var result = $.merge(list1,list2);

console.log(result.length); // it is 20,because the nodelist's length can't been modified

I think this situation is very common. Thanks!

Change History (1)

comment:1 Changed 7 years ago by dmethvin

Resolution: notabug
Status: newclosed

Working as documented. http://api.jquery.com/jquery.merge/

A Nodelist is array-like but not an Array. This method is intended mainly for our internal use. We never call it with a Nodelist as the first arg.

Note: See TracTickets for help on using tickets.