Skip to content

replaceWith doesn't work with nested elements #4072

@watermark

Description

@watermark

Not quite sure what's going on here, but I would expect it to replace the entire structure with my new string...but it injects "<item>" in an unexpected spot higher up the document tree.

Failing test

it('nested elements', () => {
  const $$ = load('<menu><item>1</item></menu>', null, false)
  const newStr = '<table><tbody><tr><td><table><tbody><tr><item>1</item></tr></tbody></table></td></tr></tbody></table>';
  const $replaced = $$('menu').replaceWith(newStr);
  expect($replaced[0].parentNode).toBe(null);
  expect($$.html()).toBe(newStr);
});
Expected :<table><tbody><tr><td><table><tbody><tr><item>1</item></tr></tbody></table></td></tr></tbody></table>
Actual   :<table><tbody><tr><td><item>1</item><table><tbody><tr></tr></tbody></table></td></tr></tbody></table>

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