salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.63k stars 395 forks source link

Forwarded synthetic shadow slots throws error when slot attribute is an expression #3885

Open jmsjtu opened 10 months ago

jmsjtu commented 10 months ago

Description

Using an expression for a slot attribute in synthetic shadow throws an error.

"DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node."

Light DOM and Native shadow do not throw the same error.

Steps to Reproduce

Stackbliz repo here.

Open the console and click on the button a few times, you'll see the error appear.

Possible Solution At some point we removed the SLOT_ATTRIBUTE_CANNOT_BE_EXPRESSION warning which enables the slot attribute to be a dynamic value but the diffing algo was not updated to accomodate this change.

I briefly debugged this and I think the root cause is because the children are reused each time a slot vnode is generated.

jmsjtu commented 10 months ago

I think this is partially related to #3731