Skip to content

Restore previous replaceWith behavior #28

@nicofrand

Description

@nicofrand

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();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions