Bug Tracker

Ticket #9258 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

clone() working with insertAfter(), but not after()

Reported by: ryanjwilke Owned by: ryanjwilke
Priority: undecided Milestone: 1.next
Component: manipulation Version: 1.6
Keywords: Cc:
Blocking: Blocked by:

Description

When running this code, I found this bug:

This doesn't work $(this).parent().clone().after($(this).parent());

This works $(this).parent().clone().insertAfter($(this).parent());

From the description in the docs, both should work.

Change History

comment:1 Changed 3 years ago by rwaldron

  • Owner set to ryanjwilke
  • Status changed from new to pending
  • Component changed from unfiled to manipulation

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, I've created this boilerplate:  http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.

comment:2 Changed 3 years ago by ajpiano

Also, please provide some more illumination as to why you think this is a bug. Those two methods are not designed to work the exact same way. The former should insert the parent element of 'this' "after" the clone - which is nowhere, because the clone isn't in the DOM. The latter is designed to actually insert the clone into the DOM at a specified location - after the parent of 'this'.

comment:3 Changed 3 years ago by ryanjwilke

  • Status changed from pending to new

Ahhh, thanks for pointing that out. I must have been confused mainly by the line: "The .after() and .insertAfter() methods perform the same task."

Maybe I took that too literally.

Thanks for the help though.

comment:4 Changed 3 years ago by ajpiano

  • Status changed from new to closed
  • Resolution set to invalid
Note: See TracTickets for help on using tickets.