jquery/jquery — pull request #920 by rvagg (2012-09-03 03:21:08+00:00)
Title: make replaceWith() clone elements where required

I thought I'd try jQuery over the new [comprehensive test suite](https://github.com/ded/bonzo/blob/master/tests/dommanip_insertions.js) we have for the various insertion methods in [Bonzo](https://github.com/ded/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).

This change pulls the call to `domManip()` up into `replaceWith()` with the basic logic that used to be performed by `before()` and `append()` used where appropriate.

With love from @Ender!