Side navigation
#12982 closed bug (notabug)
Opened November 28, 2012 07:20PM UTC
Closed November 28, 2012 07:29PM UTC
Last modified February 17, 2013 02:50PM UTC
previousSibling and nextSibling are null after using the .after method to insert an element
Reported by: | adrian.smith@activenetwork.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
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:
define(
[
],
function () {
module("jQueryAfter");
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.
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.