Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nolanlawson opened this issue Aug 8, 2024 · 0 comments
Labels
bug Synthetic Shadow Synthetic shadow DOM polyfill

Comments

@nolanlawson
Copy link
Collaborator

nolanlawson commented Aug 8, 2024

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.

@nolanlawson nolanlawson added bug Synthetic Shadow Synthetic shadow DOM polyfill labels Aug 8, 2024
@nolanlawson nolanlawson changed the title Duplicate slots and slot forwarding leads to error: Failed to execute 'removeChild' on 'Node' Synthetic shadow + duplicate slots + slot forwarding: Failed to execute 'removeChild' on 'Node' Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Synthetic Shadow Synthetic shadow DOM polyfill
Projects
None yet
Development

No branches or pull requests

1 participant