Bug Tracker

Ticket #8759 (closed bug: duplicate)

Opened 4 years ago

Last modified 9 months ago

.after() breaks on disconnected DOM node with content

Reported by: Jack <juichenieder-jq@…> Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.5.2
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 4 years ago by timmywil

  • Status changed from new to closed
  • Resolution set to duplicate

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.

comment:2 Changed 4 years ago by timmywil

Duplicate of #7369.

comment:3 Changed 3 years ago by Jonas Lundgren

This is still broken in 1.6.1

comment:4 Changed 3 years ago by timmywil

  • Priority changed from undecided to low
  • Resolution duplicate deleted
  • Status changed from closed to reopened
  • Component changed from unfiled to manipulation

Thanks. Meant to reopen this one.

comment:5 Changed 3 years ago by timmywil

  • Status changed from reopened to open

comment:7 Changed 3 years ago by john

I think we just need to make sure that the parentNode isn't a document fragment. Confirmed in triage.

comment:8 Changed 2 years ago by antishok

I think #10517 is a dupe of this one, and it was fixed in the latest 1.8b2

comment:9 Changed 2 years ago by dmethvin

  • Status changed from open to closed
  • Resolution set to duplicate

Agreed.

comment:10 Changed 2 years ago by dmethvin

Duplicate of #10517.

comment:11 Changed 9 months ago by leomontenegro6@…

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().

Note: See TracTickets for help on using tickets.