Skip to main content

Bug Tracker

Side navigation

#6455 closed bug (fixed)

Opened April 18, 2010 11:34AM UTC

Closed October 22, 2010 10:04PM UTC

Last modified October 22, 2010 10:04PM UTC

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 (0.4 KB) - added by dmethvin June 22, 2010 03:06AM UTC.

    Test case

Change History (4)

Changed June 22, 2010 03:07AM UTC by dmethvin comment:1

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

Changed September 08, 2010 12:45PM UTC by dfens comment:2

seems to be fixed on master

Changed October 22, 2010 10:04PM UTC by rwaldron comment:3

priority: → undecided
resolution: → fixed
status: newclosed

Ran test case with 1.4.3 - issue no longer occurs.

Changed October 22, 2010 10:04PM UTC by rwaldron comment:4

priority: undecidedlow