Opened 12 years ago

Closed 12 years ago

#4825 closed defect (fixed)

NodeList.adopt does not work when it is passed a NodeList as an argument

Reported by: ptwobrussell Owned by: alex
Priority: high Milestone: 1.0
Component: Core Version: 1.0
Keywords: Cc: ptwobrussell@…
Blocked By: Blocking:

Description (last modified by ptwobrussell)

/* Works */
n = document.createElement("DIV");
n.innerHTML="foobar";
dojo.query("#_div1").adopt(n);


/* Doesn't Work */
n = document.createElement("DIV");
n.innerHTML="foobar";
nl = new dojo.NodeList(n);
dojo.query("#_div1").adopt([n]);

The reason that the latter doesn't work is because the dojo.query call inside of NodeList?.adopt is creating a nested NodeList?, which is getting iterated over in the forEach call. Simple fix is to either index [0] into the dojo.query call or otherwise "fix" dojo.query to act like a no-op when it is passed a NodeList?.

Change History (2)

comment:1 Changed 12 years ago by ptwobrussell

Description: modified (diff)

comment:2 Changed 12 years ago by alex

Resolution: fixed
Status: newclosed

(In [11045]) ensure that dojo.query passes back a node list if it's inadvertently passed in. Fixes #4825

Note: See TracTickets for help on using tickets.