You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Native shadow, synthetic shadow and light DOM produce inconsistent behavior when duplicate <slot> names are used across lwc:if, lwc:elseif , and lwc:else branches.
This mostly applies to disconnectedCallback but in native shadow the connectedCallback is also affected.
Below are examples of the inconsistencies for the given component:
The slotted components are successfully mounted but are immediately unmounted.
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.
This is the only place 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 across lwc: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:
jmsjtu
changed the title
Inconsistent disconnected/connectedCallback behavior when slot is used inside lwc:if/lwc:elseif/lwc:else
Inconsistent disconnected/connectedCallback behavior when duplicate slot is used inside lwc:if/lwc:elseif/lwc:elseOct 25, 2023
jmsjtu
changed the title
Inconsistent disconnected/connectedCallback behavior when duplicate slot is used inside lwc:if/lwc:elseif/lwc:else
Inconsistent disconnected/connectedCallback behavior when duplicate slot name is used across lwc:if/lwc:elseif/lwc:else branches
Oct 25, 2023
Upon further investigation it looks like native shadow does not attempt to unmount the slotted content because the vnode containing the slot has no children.
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: