In jQuery < 1.9, replaceWith removed the current node if the content was null, undefined or an empty jQuery object.
Ex:
<div id="foo"></div>
$("#foo").replaceWith(function()
{
return $(this).contents();
});
Expected Result :
DIV#foo is removed (ok in jQuery 1.8.3)
Actual result:
DIV#foo still exists.
How to restore the previous behavior :
$("#foo").remove(":empty").replaceWith(function()
{
return $(this).contents();
});