@lwc/engine-core 2.41.1 → 2.41.3

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.
@@ -3809,8 +3809,7 @@ function mountComment(vnode, parent, anchor, renderer) {
3809
3809
  function mountFragment(vnode, parent, anchor, renderer) {
3810
3810
  const { children } = vnode;
3811
3811
  mountVNodes(children, parent, renderer, anchor);
3812
- // children of a fragment will always have at least the two delimiters.
3813
- vnode.elm = children[children.length - 1].elm;
3812
+ vnode.elm = vnode.leading.elm;
3814
3813
  }
3815
3814
  function patchFragment(n1, n2, parent, renderer) {
3816
3815
  const { children, stable } = n2;
@@ -3821,7 +3820,7 @@ function patchFragment(n1, n2, parent, renderer) {
3821
3820
  updateDynamicChildren(n1.children, children, parent, renderer);
3822
3821
  }
3823
3822
  // Note: not reusing n1.elm, because during patching, it may be patched with another text node.
3824
- n2.elm = children[children.length - 1].elm;
3823
+ n2.elm = n2.leading.elm;
3825
3824
  }
3826
3825
  function mountElement(vnode, parent, anchor, renderer) {
3827
3826
  const { sel, owner, data: { svg }, } = vnode;
@@ -4039,6 +4038,26 @@ function updateTextContent(vnode, renderer) {
4039
4038
  lockDomMutation();
4040
4039
  }
4041
4040
  }
4041
+ function insertFragmentOrNode(vnode, parent, anchor, renderer) {
4042
+ if (process.env.NODE_ENV !== 'production') {
4043
+ unlockDomMutation();
4044
+ }
4045
+ if (isVFragment(vnode)) {
4046
+ const children = vnode.children;
4047
+ for (let i = 0; i < children.length; i += 1) {
4048
+ const child = children[i];
4049
+ if (!shared.isNull(child)) {
4050
+ renderer.insert(child.elm, parent, anchor);
4051
+ }
4052
+ }
4053
+ }
4054
+ else {
4055
+ renderer.insert(vnode.elm, parent, anchor);
4056
+ }
4057
+ if (process.env.NODE_ENV !== 'production') {
4058
+ lockDomMutation();
4059
+ }
4060
+ }
4042
4061
  function insertNode(node, parent, anchor, renderer) {
4043
4062
  if (process.env.NODE_ENV !== 'production') {
4044
4063
  unlockDomMutation();
@@ -4325,14 +4344,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4325
4344
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4326
4345
  // Vnode moved right
4327
4346
  patch(oldStartVnode, newEndVnode, parent, renderer);
4328
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4347
+ // In the case of fragments, the `elm` property of a vfragment points to the leading
4348
+ // anchor. To determine the next sibling of the whole fragment, we need to use the
4349
+ // trailing anchor as the argument to nextSibling():
4350
+ // [..., [leading, ...content, trailing], nextSibling, ...]
4351
+ let anchor;
4352
+ if (isVFragment(oldEndVnode)) {
4353
+ anchor = renderer.nextSibling(oldEndVnode.trailing.elm);
4354
+ }
4355
+ else {
4356
+ anchor = renderer.nextSibling(oldEndVnode.elm);
4357
+ }
4358
+ insertFragmentOrNode(oldStartVnode, parent, anchor, renderer);
4329
4359
  oldStartVnode = oldCh[++oldStartIdx];
4330
4360
  newEndVnode = newCh[--newEndIdx];
4331
4361
  }
4332
4362
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4333
4363
  // Vnode moved left
4334
4364
  patch(oldEndVnode, newStartVnode, parent, renderer);
4335
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4365
+ insertFragmentOrNode(newStartVnode, parent, oldStartVnode.elm, renderer);
4336
4366
  oldEndVnode = oldCh[--oldEndIdx];
4337
4367
  newStartVnode = newCh[++newStartIdx];
4338
4368
  }
@@ -4366,7 +4396,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4366
4396
  }
4367
4397
  // We've already cloned at least once, so it's no longer read-only
4368
4398
  oldCh[idxInOld] = undefined;
4369
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4399
+ insertFragmentOrNode(elmToMove, parent, oldStartVnode.elm, renderer);
4370
4400
  }
4371
4401
  }
4372
4402
  newStartVnode = newCh[++newStartIdx];
@@ -4473,14 +4503,18 @@ function st(fragment, key) {
4473
4503
  }
4474
4504
  // [fr]agment node
4475
4505
  function fr(key, children, stable) {
4506
+ const leading = t('');
4507
+ const trailing = t('');
4476
4508
  return {
4477
4509
  type: 5 /* VNodeType.Fragment */,
4478
4510
  sel: undefined,
4479
4511
  key,
4480
4512
  elm: undefined,
4481
- children: [t(''), ...children, t('')],
4513
+ children: [leading, ...children, trailing],
4482
4514
  stable,
4483
4515
  owner: getVMBeingRendered(),
4516
+ leading,
4517
+ trailing,
4484
4518
  };
4485
4519
  }
4486
4520
  // [h]tml node
@@ -6989,5 +7023,5 @@ exports.swapTemplate = swapTemplate;
6989
7023
  exports.track = track;
6990
7024
  exports.unwrap = unwrap;
6991
7025
  exports.wire = wire;
6992
- /* version: 2.41.1 */
7026
+ /* version: 2.41.3 */
6993
7027
  //# sourceMappingURL=engine-core.cjs.js.map