Ticket #7354 (closed bug: wontfix)
order of cloned modified elements mismatches
| Reported by: | thorstengiese@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.5 |
| Component: | unfiled | Version: | 1.4.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
With more than 8 elements in the "orig"-div, jQuery mixes up the order in the "copy"-div.
Here is the code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="orig">
<div class="elem"><a>1</a></div>
<div class="elem"><a>2</a></div>
<div class="elem"><a>3</a></div>
<div class="elem"><a>4</a></div>
<div class="elem"><a>5</a></div>
<div class="elem"><a>6</a></div>
<div class="elem"><a>7</a></div>
<div class="elem"><a>8</a></div>
<div class="elem"><a>9</a></div>
</div>
<div id="copy"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script>
$(function() {
$('#copy').append($('.elem').clone().children('a').prepend('foo - ').parent().clone());
});
</script>
</body>
</html>
Change History
comment:2 Changed 3 years ago by thorstengiese@…
Additional Info: Works fine on Safari/iPad, seems to be Browser dependend. Firefox 3.6 under Windows 7 was used for detection.
comment:3 Changed 3 years ago by snover
I am 99% sure this is not a jQuery bug. Your code is cloning a collection of elements that is not attached to any DOM and so has no order. The revised test case contains the correct code for doing what you are trying to do, and the order is consistent.
comment:4 Changed 3 years ago by jitter
I agree with snover.
The following is just further info.
The test provided by anonymous (thorstengiese ?) in Opera inserts them in reverse order 9,8,...,2,1. But just adapting the test to correct jsfiddle conventions fixes it for Opera as in snovers revised testcase both calls insert in correct order 1,2,...,8,9. But in FF 3.6 only the second (correct) usage works.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

as requested: http://jsfiddle.net/DamrH/