Ticket #12449 (closed bug: fixed)
replaceWith() doesn't clone elements where required
| Reported by: | rod@… | Owned by: | rod@… |
|---|---|---|---|
| Priority: | high | Milestone: | 1.9 |
| Component: | manipulation | Version: | 1.8.0 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
(from https://github.com/jquery/jquery/pull/920)
I thought I'd try jQuery over the new comprehensive test suite we have for the various insertion methods in Bonzo and discovered that jQuery's replaceWith() wasn't properly cloning where required.
Inside replaceWith() this.each() is used which then passes a singular collection for each element in this to before() or append() which then invokes domManip(), the clone check inside domManip() (see iNoClone = results.cacheable || l - 1 -- l always == 1).
Change History
comment:1 Changed 9 months ago by timmywil
- Priority changed from undecided to high
- Status changed from new to open
- Component changed from unfiled to manipulation
comment:3 Changed 9 months ago by rod@…
- Status changed from pending to new
@timmywil: this should do it: http://jsfiddle.net/fHhKf/4/
comment:5 Changed 9 months ago by dmethvin
- Milestone changed from None to 1.9
See additional discussion in https://github.com/jquery/jquery/pull/920
comment:7 Changed 6 months ago by Rod Vagg
- Status changed from assigned to closed
- Resolution set to fixed
Fixes #12449. make replaceWith() clone elements where required. Closes gh-920
Changeset: 551c2c9f4ac776b6d53600c452ad40a4b4d6670b
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for writing tests in the pull! Just for clarity's sake, do you have a fiddle somewhere that also demonstrates the problem?