Skip to content

Synthetic shadow + duplicate slots + slot forwarding: Failed to execute 'removeChild' on 'Node' #4451

Open
@nolanlawson

Description

@nolanlawson

Somewhat related to #4446.

It turns out that slot forwarding is buggy in synthetic shadow DOM when using synthetic custom element lifecycle.

Minimal StackBlitz repro

If you look in the DevTools console, you'll see an unhandled promise rejection:

Unhandled promise rejection: NotFoundError: Failed to execute 'removeChild' on 'Node':
The node to be removed is not a child of this node.

This is caused by this line:

renderer.remove(node, parent);

Specifically when called in unmount:

if (doRemove && type !== VNodeType.Fragment) {
// The vnode might or might not have a data.renderer associated to it
// but the removal used here is from the owner instead.
removeNode(elm!, parent, renderer);
}

This bug repros only in synthetic shadow, not native shadow. It repros with both native and synthetic custom element lifecycle.

The bug goes back to LWC v3.0.0 (at least), so it's probably been there for a while.

This is also repro'd by 5035243 and this test for #3827:

fixtures.forEach(({ fixtureName, tagName, ctor, ifBlock, elseBlock, elseIfBlock }) => {
// #TODO[3827]: These regression tests can be removed once the bug is resolved.

The best way to repro is to run DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE=1 yarn start and look in the DevTools console.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions