Ticket #11338 (closed bug: fixed)
Inconsistent behavior with .replaceWith() and disconnected nodes.
| Reported by: | https://github.com/ironchefpython | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.8 |
| Component: | manipulation | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I noticed odd behavior using replaceWith on disconnected nodes. I use a lot of html fragments, and I was getting strange results depending on the presence or absence of text.
Here is the minimal test case:
> jQuery("<span></span>").replaceWith("<div></div>");
[<div></div>]
>jQuery("<span>foo</span>").replaceWith("<div>bar</div>");
[<span>foo</span>]
This bug may be a duplicate of http://bugs.jquery.com/ticket/7246, however that was closed 15 months ago with no indication of if the non-deterministic behavior is intended.
Change History
comment:1 Changed 16 months ago by timmywil
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to manipulation
comment:2 Changed 14 months ago by sindresorhus
Pull request: https://github.com/jquery/jquery/pull/721
comment:3 Changed 12 months ago by Oleg
- Status changed from open to closed
- Resolution set to fixed
Fixes #11338, .replaceWith should work on detached nodes.
Changeset: c04bfce556616a60cecf0ecaf9cb1f9d048a4747
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Confirmed. http://jsfiddle.net/timmywil/TFTwC/