Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7303 closed bug (invalid)

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

Reported by: petri.lehtinen@… 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>

Change History (6)

comment:1 Changed 9 years ago by petri.lehtinen@…

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

comment:2 Changed 9 years ago by jyrki.pulliainen@…

comment:3 Changed 9 years ago by addyosmani

Keywords: appendto object added
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.

comment:4 Changed 9 years ago by addyosmani

Keywords: needsreview added

comment:5 Changed 9 years ago by dmethvin

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.

comment:6 Changed 9 years ago by dmethvin

Keywords: needsreview removed
Note: See TracTickets for help on using tickets.