[jQuery] how to relocate elements without losing data?

[jQuery] how to relocate elements without losing data?


I've had to write a big workaround to a problem I'm having. I've been
creating an application which involves me extracting DOM elements and
inserting them back elsewhere in the page.
I have to remove() them first before inserting them elsewhere because
otherwise the browser (Firefox in my case) complains about trying to
insert an element that's already a part of the DOM. I then call
insertBefore() (or similar) to complete the relocation operation.
So in essence, I'm not really removing the element, just changing its
location in the DOM. The problem is, I'm also (or was, anyway) making
heavy use of the data() method which suddenly became a big problem
upon realising that the act of calling remove() clears the data I
stored.
Why is the data cleared when I call remove()? Why is it assumed that I
don't want to reinsert the element and retain the data?
Why is there no easy way to grab a copy of the entire data cache for
that element so it can be preserved?
Alternatively, why is there no option to retain the data rather than
the default behaviour, which removes the data?