Testcase for jQuery Ticket 7246

Calling replaceWith( newContent) on a jQuery object which didn't match any elements returns the "newContent" instead of the original jQuery Object. This probably results from the new added behavior in 1.4 that replaceWith also can work on disconnected nodes and there returns also the newContent

by jitter

HTML

<p class="none">I'm a p</p>
<p class="none">I'm a p too</p>
<p>
    <input id="re" type="button" value="  replaceWith matched elements " />
    &nbsp;
    <input id="nre" type="button" value=" replaceWith no elements matched " />
</p>
<p>Here the return of the replaceWith calls are appended</p>
<div id="bin" />

CSS

#bin {
    width: 500px;
    height: 100px;
    border: 1px solid black;
}

JavaScript

$("#re").click(function() {
    $(".none").replaceWith("<h1 style='color:red'>I'm a h1</h1>").appendTo("#bin");
});
$("#nre").click(function() {
    $("#notexisting").replaceWith("<h1 style='color:red'>I'm a h1 too</h1>").appendTo("#bin");
});