Skip to main content

Bug Tracker

Side navigation

#6439 closed bug (fixed)

Opened April 14, 2010 10:22PM UTC

Closed March 30, 2011 08:03PM UTC

Last modified March 13, 2012 08:50PM UTC

append() removes all data when used on multiple elements

Reported by: thesaint Owned by:
Priority: undecided Milestone:
Component: manipulation Version: 1.4.2
Keywords: append data events Cc:
Blocked by: Blocking:

When a fragment with data is created and it is appended with "append()" to multiple elements, the fragment is inserted without the data (thus, event handlers are also wiped). "appendTo()" doesn't show this behavior. Also, when "append()" is used for a single element, the data isn't lost. See the attached file.

Attachments (1)
  • jqerror.html (0.5 KB) - added by thesaint April 14, 2010 10:22PM UTC.
Change History (7)

Changed April 15, 2010 12:17AM UTC by dmethvin comment:1

I can see how this would happen, since the elements have to be cloned to append to multiple locations. Were you expecting to see the data cloned into new separate objects that would be associated with the elements? Or would you expect the elements to all share the original common data object?

Changed April 15, 2010 05:41AM UTC by thesaint comment:2

Hmm, firstly I expected the data to be there ''at all'' :-)

Here are my thoughts: The most important use case for data are bound events. From a memory perspective it seems better to me when the event handler is shared across all elements. And at the moment I can't think of a scenario where cloned event handlers are more useful than shared event handlers. What happens when you call .bind() on multiple elements, is the handler cloned? What's the behavior of appendTo()? I think consistency is a good thing here.

Changed November 12, 2010 02:40AM UTC by snover comment:3

milestone: 1.4.3

Resetting milestone to future.

Changed November 20, 2010 05:36PM UTC by dmethvin comment:4

priority: → undecided
status: newopen

Changed November 20, 2010 05:48PM UTC by dmethvin comment:5

I guess this is a case of two cases that look similar justifiably doing very different things.

For the case

I think we *want* to have everything preserved; we are just moving #elem1 to another point in the DOM tree. For example you might move an option element between two select boxes.


I am less confident. (For one, if it were truly an element with an id you've created an invalid document but let's ignore that for a second.) I can see a strong case for cloning the attached data (and thus the events as well).

Changed March 30, 2011 08:01PM UTC by danheberden comment:6

Seems to be working properly -

Changed March 30, 2011 08:03PM UTC by danheberden comment:7

resolution: → fixed
status: openclosed