Ticket #6455 (closed bug: fixed)
Strange behaviour of jQuery(elementArray)
| Reported by: | tomtom | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.4.3 |
| Component: | manipulation | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I just tried to migrate my Project from 1.3.2 to 1.4.2 and found a bug in the new version. I've got an array of pure DOM Elements that all have to be appended to another element at once. But since 1.4.2 only the first element of the array gets appended. The strange thing is, that when I debug the code using firebug, all elements get appended so I presume there is a race condition somewhere. I reproduced the bug using the following code:
<html>
<head>
<script src='http://code.jquery.com/jquery-1.4.2.min.js'></script>
<script>
$(document).ready(function() {
var test=[];
for (var i=0; i<10;i++) {
test.push($("<li>test"+i+"</li>")[0]);
}
$(test).appendTo($('#list'));
});
</script>
</head>
<body>
<ul id='list'></ul>
</body>
</html>
I found a workaround for the meantime. Before calling $(test).appendTo($('#list')); I convert all array elements to jQuery objects:
for (i=0; i<test.length; i++) {
test[i] = $(test[i]);
}
$(test).appendTo($('#list'));
Tested with Firefox 3.6.3 and Chrome 5.
Attachments
Change History
Changed 3 years ago by dmethvin
-
attachment
test-6455.html
added
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Test case