Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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:
Blocked by: Blocking:

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 (1)

test-6455.html (389 bytes) - added by dmethvin 13 years ago.
Test case

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by dmethvin

Attachment: test-6455.html added

Test case

comment:1 Changed 13 years ago by dmethvin

Seemed crazy but sure enough ... test case attached.

comment:2 Changed 13 years ago by dfens

seems to be fixed on master

comment:3 Changed 13 years ago by Rick Waldron

Priority: undecided
Resolution: fixed
Status: newclosed

Ran test case with 1.4.3 - issue no longer occurs.

comment:4 Changed 13 years ago by Rick Waldron

Priority: undecidedlow
Note: See TracTickets for help on using tickets.