Skip to main content

Bug Tracker

Side navigation

#7303 closed bug (invalid)

Opened October 25, 2010 08:08AM UTC

Closed October 25, 2010 09:19PM UTC

Last modified November 02, 2010 02:14AM UTC

Regression: Cannot use appendTo() with a jQuery object that holds many elements

Reported by: petri.lehtinen@inoi.fi Owned by:
Priority: low Milestone: 1.5
Component: unfiled Version: 1.4.3
Keywords: appendto object Cc:
Blocked by: Blocking:
Description

I have a jQuery object to which I push two elements. Then I use .appendTo() to append these elements into another element. This works in 1.4.2 but not in 1.4.3.

Here's an example:

<!doctype html>
<html>
  <head>
    <title>jQuery test</title>
    <!-- use 1.4.2 if you want to see it work -->
    <script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
  </head>
  <body>
    <div id="target"></span>

    <script>
(function() {
    var container = $();
    container.push($('<span>foo</span>'));
    container.push($('<span>bar</span>'));
    container.appendTo($('#target'))
})();
    </script>
  </body>
</html>
Attachments (0)
Change History (6)

Changed October 25, 2010 08:10AM UTC by petri.lehtinen@inoi.fi comment:1

Sorry about pasting code to the ticket. This is my first ticket and I only found out after posting that jsFiddle is preferred.

Changed October 25, 2010 08:17AM UTC by jyrki.pulliainen@inoi.fi comment:2

Changed October 25, 2010 02:38PM UTC by addyosmani comment:3

keywords: → appendto object
priority: undecidedlow
status: newopen

There are much simpler ways this problem could be coded, but I've tested your original code out in 1.4.3 (and our latest version from Git) and it does indeed appear to be broken with both. Opening as a valid ticket and flagging for further review.

Changed October 25, 2010 02:42PM UTC by addyosmani comment:4

keywords: appendto objectappendto object needsreview

Changed October 25, 2010 09:19PM UTC by dmethvin comment:5

resolution: → invalid
status: openclosed

A jQuery object should contain an array of DOM elements, not other jQuery objects. Also, there has never been a documented method

.push
on a jQuery object.

Changed November 02, 2010 02:14AM UTC by dmethvin comment:6

keywords: appendto object needsreviewappendto object