Bug Tracker

Modify

Ticket #6455 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

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

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

Change History

Changed 3 years ago by dmethvin

Test case

comment:1 Changed 3 years ago by dmethvin

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

comment:2 Changed 3 years ago by dfens

seems to be fixed on master

comment:3 Changed 3 years ago by rwaldron

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to fixed

Ran test case with 1.4.3 - issue no longer occurs.

comment:4 Changed 3 years ago by rwaldron

  • Priority changed from undecided to low

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.