An alternative would be to call cloneNode() for each DOM node before appending to the DOM tree. Here is a small untested function to illustrate:
function appendChildNodeClones(parent, /* ... */) { var args = flattenArguments(arguments); for (var i = 1; i < args.length; i++) { if (args[i] != null && typeof(args[i].cloneNode) == "function") { parent.appendChild(args[i].cloneNode(true)); } else { appendChildNodes(parent, args[i]); } } } /Per On Mon, Apr 28, 2008 at 1:40 AM, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > > machineghost schrieb: > > > It turns out the problem is with both of our understanding of repeat > > Ah, yes! Thanks for your analysis, now everything makes sense. > > I could use the excuse that I usually program in Python, not in > Javascript, but in fact repeat() does not behave differently there ;-) > > To summarize, the Test2 code based on two subtle misconceptions. First, > the implicit idea that in the expression repeat(BR()) the BR() is either > evaluated on every repetition, or copies of the BR() object are created > on every repetition, which both is of course not the case. Second, the > idea that you don't need to care whether elements you're adding to the > DOM are already used elsewhere ;-) > > Your solution > > > var brAdder = function(x) { return [x, BR()]; } > appendChildNodes("test2", map(brAdder, text)); > > is nice. Alternatively, the Test2 code be fixed as follows: > > appendChildNodes("test2", izip(text, imap(BR, repeat()))); > > Just to make use of repeat() against these odds... > > > > -- Christoph > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---