Inconsistent disconnected/connectedCallback
behavior when duplicate slot
name is used across lwc:if
/lwc:elseif
/lwc:else
branches
#3827
Labels
Description
Native shadow, synthetic shadow and light DOM produce inconsistent behavior when duplicate
<slot>
names are used acrosslwc:if
,lwc:elseif
, andlwc:else
branches.This mostly applies to
disconnectedCallback
but in native shadow theconnectedCallback
is also affected.Below are examples of the inconsistencies for the given component:
Synthetic shadow:
Native lifecycle disabled
Native lifecycle enabled
Light DOM
Native lifecycle disabled
Native lifecycle enabled
Native shadow
An example can be found here, for both native and synthetic lifecycle the components are only mounted a single time and are never unmounted/remounted.
connectedCallback
is affected.Possible Causes
In debugging the
<slot>
behavior, I believe the issue may be related to the fact that the VNodes representing each<slot>
(named or default) generated in the slot API are shared acrosslwc:if
branches.By nature of using fragments, the dynamic diffing algo causes
<slot>
content to be mounted before unmounting.Since the mounting occurs before unmounting and
<slot>
VNode references are shared across branches, reference to the previous<slot>
VM
and element are lost prior to unmounting.This may be causing the discrepancy we're observing.
The text was updated successfully, but these errors were encountered: