Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#12982 closed bug (notabug)

previousSibling and nextSibling are null after using the .after method to insert an element

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:


When I use .after() to insert an item into the DOM tree, the item is inserted but the nextSibling of the item I am inserting after isn't set and the previousSibling of the item I am inserting is also left as null. Sample code:


[ ],

function () {


test("after", function () {

var $html = $("<input type='text'/>");

var $datePicker = $('<button class="calendar"></button>'); $html.after($datePicker); var nextItem = $html.next(); var prevItem = $datePicker.prev(); equal(nextItem.length, 1, "Correct next item"); equal(prevItem.length, 1, "Correct prev item");




When run in qunit this fails. It worked in 1.7.2.

Change History (2)

comment:1 Changed 10 years ago by dmethvin

Resolution: notabug
Status: newclosed

There have been several bugs in the implementation of .before() and .after() with detached elements over several versions. After looking at the semantics we decided that it was trying to serve too many use cases. As of 1.9, they don't work on detached elements at all. More information will be coming in the 1.9 upgrade guide.

comment:2 Changed 10 years ago by gibson042

#13462 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.