@lwc/engine-core 2.41.1 → 2.41.2

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.
@@ -3807,8 +3807,7 @@ function mountComment(vnode, parent, anchor, renderer) {
3807
3807
  function mountFragment(vnode, parent, anchor, renderer) {
3808
3808
  const { children } = vnode;
3809
3809
  mountVNodes(children, parent, renderer, anchor);
3810
- // children of a fragment will always have at least the two delimiters.
3811
- vnode.elm = children[children.length - 1].elm;
3810
+ vnode.elm = vnode.leading.elm;
3812
3811
  }
3813
3812
  function patchFragment(n1, n2, parent, renderer) {
3814
3813
  const { children, stable } = n2;
@@ -3819,7 +3818,7 @@ function patchFragment(n1, n2, parent, renderer) {
3819
3818
  updateDynamicChildren(n1.children, children, parent, renderer);
3820
3819
  }
3821
3820
  // Note: not reusing n1.elm, because during patching, it may be patched with another text node.
3822
- n2.elm = children[children.length - 1].elm;
3821
+ n2.elm = n2.leading.elm;
3823
3822
  }
3824
3823
  function mountElement(vnode, parent, anchor, renderer) {
3825
3824
  const { sel, owner, data: { svg }, } = vnode;
@@ -4037,6 +4036,26 @@ function updateTextContent(vnode, renderer) {
4037
4036
  lockDomMutation();
4038
4037
  }
4039
4038
  }
4039
+ function insertFragmentOrNode(vnode, parent, anchor, renderer) {
4040
+ if (process.env.NODE_ENV !== 'production') {
4041
+ unlockDomMutation();
4042
+ }
4043
+ if (isVFragment(vnode)) {
4044
+ const children = vnode.children;
4045
+ for (let i = 0; i < children.length; i += 1) {
4046
+ const child = children[i];
4047
+ if (!isNull(child)) {
4048
+ renderer.insert(child.elm, parent, anchor);
4049
+ }
4050
+ }
4051
+ }
4052
+ else {
4053
+ renderer.insert(vnode.elm, parent, anchor);
4054
+ }
4055
+ if (process.env.NODE_ENV !== 'production') {
4056
+ lockDomMutation();
4057
+ }
4058
+ }
4040
4059
  function insertNode(node, parent, anchor, renderer) {
4041
4060
  if (process.env.NODE_ENV !== 'production') {
4042
4061
  unlockDomMutation();
@@ -4323,14 +4342,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4323
4342
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4324
4343
  // Vnode moved right
4325
4344
  patch(oldStartVnode, newEndVnode, parent, renderer);
4326
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4345
+ // In the case of fragments, the `elm` property of a vfragment points to the leading
4346
+ // anchor. To determine the next sibling of the whole fragment, we need to use the
4347
+ // trailing anchor as the argument to nextSibling():
4348
+ // [..., [leading, ...content, trailing], nextSibling, ...]
4349
+ let anchor;
4350
+ if (isVFragment(oldEndVnode)) {
4351
+ anchor = renderer.nextSibling(oldEndVnode.trailing.elm);
4352
+ }
4353
+ else {
4354
+ anchor = renderer.nextSibling(oldEndVnode.elm);
4355
+ }
4356
+ insertFragmentOrNode(oldStartVnode, parent, anchor, renderer);
4327
4357
  oldStartVnode = oldCh[++oldStartIdx];
4328
4358
  newEndVnode = newCh[--newEndIdx];
4329
4359
  }
4330
4360
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4331
4361
  // Vnode moved left
4332
4362
  patch(oldEndVnode, newStartVnode, parent, renderer);
4333
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4363
+ insertFragmentOrNode(newStartVnode, parent, oldStartVnode.elm, renderer);
4334
4364
  oldEndVnode = oldCh[--oldEndIdx];
4335
4365
  newStartVnode = newCh[++newStartIdx];
4336
4366
  }
@@ -4364,7 +4394,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4364
4394
  }
4365
4395
  // We've already cloned at least once, so it's no longer read-only
4366
4396
  oldCh[idxInOld] = undefined;
4367
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4397
+ insertFragmentOrNode(elmToMove, parent, oldStartVnode.elm, renderer);
4368
4398
  }
4369
4399
  }
4370
4400
  newStartVnode = newCh[++newStartIdx];
@@ -4471,14 +4501,18 @@ function st(fragment, key) {
4471
4501
  }
4472
4502
  // [fr]agment node
4473
4503
  function fr(key, children, stable) {
4504
+ const leading = t('');
4505
+ const trailing = t('');
4474
4506
  return {
4475
4507
  type: 5 /* VNodeType.Fragment */,
4476
4508
  sel: undefined,
4477
4509
  key,
4478
4510
  elm: undefined,
4479
- children: [t(''), ...children, t('')],
4511
+ children: [leading, ...children, trailing],
4480
4512
  stable,
4481
4513
  owner: getVMBeingRendered(),
4514
+ leading,
4515
+ trailing,
4482
4516
  };
4483
4517
  }
4484
4518
  // [h]tml node
@@ -6950,5 +6984,5 @@ function readonly(obj) {
6950
6984
  }
6951
6985
 
6952
6986
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6953
- /* version: 2.41.1 */
6987
+ /* version: 2.41.2 */
6954
6988
  //# sourceMappingURL=engine-core.js.map