@lwc/engine-core 7.1.4 → 7.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5248,14 +5248,33 @@ function s(slotName, data, children, slotset) {
5248
5248
  if (renderMode === 0 /* RenderMode.Light */ &&
5249
5249
  isAPIFeatureEnabled(6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */, apiVersion) &&
5250
5250
  (isVBaseElement(vnode) || isVStatic(vnode)) &&
5251
- // We only need to copy the vnodes when the slot assignment changes, copying every time causes issues with
5252
- // disconnected/connected callback firing.
5253
5251
  vnode.slotAssignment !== data.slotAssignment) {
5254
- // When the light DOM slot assignment (slot attribute) changes we can't use the same reference
5255
- // to the vnode because the current way the diffing algo works, it will replace the original reference
5256
- // to the host element with a new one. This means the new element will be mounted and immediately unmounted.
5257
- // Creating a copy of the vnode to preserve a reference to the previous host element.
5252
+ // When the light DOM slot assignment (slot attribute) changes, we can't use the same reference
5253
+ // to the vnode because the current way the diffing algo works, it will replace the original
5254
+ // reference to the host element with a new one. This means the new element will be mounted and
5255
+ // immediately unmounted. Creating a copy of the vnode preserves a reference to the previous
5256
+ // host element.
5258
5257
  clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
5258
+ // For disconnectedCallback to work correctly in synthetic lifecycle mode, we need to link the
5259
+ // current VM's velements to the clone, so that when the VM unmounts, the clone also unmounts.
5260
+ // Note this only applies to VCustomElements, since those are the elements that we manually need
5261
+ // to call disconnectedCallback for, when running in synthetic lifecycle mode.
5262
+ //
5263
+ // You might think it would make more sense to add the clonedVNode to the same velements array
5264
+ // as the original vnode's VM (i.e. `vnode.owner.velements`) rather than the current VM (i.e.
5265
+ // `vmBeingRendered.velements`), but this actually might not trigger disconnectedCallback
5266
+ // in synthetic lifecycle mode. The reason for this is that a reactivity change may cause
5267
+ // the slottable component to unmount, but _not_ the slotter component (see issue #4446).
5268
+ //
5269
+ // If this occurs, then the slottable component (i.e .this component we are rendering right
5270
+ // now) is the one that needs to own the clone. Whereas if a reactivity change higher in the
5271
+ // tree causes the slotter to unmount, then the slottable will also unmount. So using the
5272
+ // current VM works either way.
5273
+ if (lwcRuntimeFlags.ENABLE_SLOT_FORWARDING_FIX) {
5274
+ if (isVCustomElement(vnode)) {
5275
+ addVNodeToChildLWC(clonedVNode);
5276
+ }
5277
+ }
5259
5278
  }
5260
5279
  // If the slot content is standard type, the content is static, no additional
5261
5280
  // processing needed on the vnode
@@ -8052,5 +8071,5 @@ function readonly(obj) {
8052
8071
  }
8053
8072
 
8054
8073
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8055
- /** version: 7.1.4 */
8074
+ /** version: 7.1.5 */
8056
8075
  //# sourceMappingURL=index.js.map