#8759 closed bug (duplicate)
.after() breaks on disconnected DOM node with content
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | manipulation | Version: | 1.5.2 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
Ok, quick description.
This works as expected (it returns a set of 2 dom nodes):
$('<div></div>').after('<p></p>')
This does not work (it returns only the first of the 2 dom nodes):
$('<div>f</div>').after('<p></p>')
Change History (11)
comment:1 Changed 11 years ago by
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
comment:4 Changed 11 years ago by
| Component: | unfiled → manipulation |
|---|---|
| Priority: | undecided → low |
| Resolution: | duplicate |
| Status: | closed → reopened |
Thanks. Meant to reopen this one.
comment:5 Changed 11 years ago by
| Status: | reopened → open |
|---|
comment:7 Changed 11 years ago by
I think we just need to make sure that the parentNode isn't a document fragment. Confirmed in triage.
comment:8 Changed 10 years ago by
I think #10517 is a dupe of this one, and it was fixed in the latest 1.8b2
comment:11 Changed 8 years ago by
Strangely, I'm getting the same issue after updating jQuery from 1.8.2 to 1.11.0. The $.after() and $.before() methods aren't working on newly created elements. I need to firstly add the newly created element to DOM, and then insert the new content to it. Dunno if it's a bug, of if these methods were changed.
Anyway, a workaround for this is using $.add() method, but it will work only as a alternative to $.after() method, not $.before().

We fixed this issue in closest for 1.6, but there is probably an underlying issue we should take a closer look at. Closing as duplicate.