lwc 2.22.0 → 2.23.0

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.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +58 -114
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +58 -114
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +56 -112
  5. package/dist/engine-dom/iife/es5/engine-dom.js +61 -123
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +59 -121
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +58 -114
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +56 -112
  11. package/dist/engine-dom/umd/es5/engine-dom.js +61 -123
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +59 -121
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +54 -132
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +54 -132
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +13 -10
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +13 -10
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +13 -10
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +15 -14
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +15 -14
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +13 -10
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +13 -10
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +15 -14
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +15 -14
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -291,7 +291,7 @@ var LWC = (function (exports) {
291
291
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
292
292
  return attributeName;
293
293
  }
294
- /** version: 2.22.0 */
294
+ /** version: 2.23.0 */
295
295
 
296
296
  /*
297
297
  * Copyright (c) 2018, salesforce.com, inc.
@@ -859,6 +859,14 @@ var LWC = (function (exports) {
859
859
  }
860
860
  });
861
861
 
862
+ function updateComponentValue(vm, key, newValue) {
863
+ const { cmpFields } = vm;
864
+ if (newValue !== cmpFields[key]) {
865
+ cmpFields[key] = newValue;
866
+ componentValueMutated(vm, key);
867
+ }
868
+ }
869
+
862
870
  /**
863
871
  * Copyright (C) 2017 salesforce.com, inc.
864
872
  */
@@ -1342,10 +1350,7 @@ var LWC = (function (exports) {
1342
1350
  },
1343
1351
  set(newValue) {
1344
1352
  const vm = getAssociatedVM(this);
1345
- if (newValue !== vm.cmpProps[propName]) {
1346
- vm.cmpProps[propName] = newValue;
1347
- componentValueMutated(vm, propName);
1348
- }
1353
+ updateComponentValue(vm, propName, newValue);
1349
1354
  return set.call(vm.elm, newValue);
1350
1355
  },
1351
1356
  };
@@ -1574,10 +1579,7 @@ var LWC = (function (exports) {
1574
1579
  },
1575
1580
  set(newValue) {
1576
1581
  const vm = getAssociatedVM(this);
1577
- if (newValue !== vm.cmpFields[key]) {
1578
- vm.cmpFields[key] = newValue;
1579
- componentValueMutated(vm, key);
1580
- }
1582
+ updateComponentValue(vm, key, newValue);
1581
1583
  },
1582
1584
  enumerable: true,
1583
1585
  configurable: true,
@@ -1729,10 +1731,7 @@ var LWC = (function (exports) {
1729
1731
  set(newValue) {
1730
1732
  const vm = getAssociatedVM(this);
1731
1733
  const reactiveOrAnyValue = getReactiveProxy(newValue);
1732
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1733
- vm.cmpFields[key] = reactiveOrAnyValue;
1734
- componentValueMutated(vm, key);
1735
- }
1734
+ updateComponentValue(vm, key, reactiveOrAnyValue);
1736
1735
  },
1737
1736
  enumerable: true,
1738
1737
  configurable: true,
@@ -1768,10 +1767,7 @@ var LWC = (function (exports) {
1768
1767
  * letting the author to do the wrong thing, but it will keep our
1769
1768
  * system to be backward compatible.
1770
1769
  */
1771
- if (value !== vm.cmpFields[key]) {
1772
- vm.cmpFields[key] = value;
1773
- componentValueMutated(vm, key);
1774
- }
1770
+ updateComponentValue(vm, key, value);
1775
1771
  },
1776
1772
  enumerable: true,
1777
1773
  configurable: true,
@@ -2440,13 +2436,13 @@ var LWC = (function (exports) {
2440
2436
  return owner;
2441
2437
  }
2442
2438
  function createStylesheet(vm, stylesheets) {
2443
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
2439
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
2444
2440
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
2445
2441
  for (let i = 0; i < stylesheets.length; i++) {
2446
2442
  insertStylesheet(stylesheets[i]);
2447
2443
  }
2448
2444
  }
2449
- else if (ssr || vm.hydrated) {
2445
+ else if (vm.hydrated) {
2450
2446
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
2451
2447
  // This works in the client, because the stylesheets are created, and cached in the VM
2452
2448
  // the first time the VM renders.
@@ -2743,7 +2739,7 @@ var LWC = (function (exports) {
2743
2739
  updateStaticChildren(c1, c2, parent, renderer);
2744
2740
  }
2745
2741
  }
2746
- function patch(n1, n2, renderer) {
2742
+ function patch(n1, n2, parent, renderer) {
2747
2743
  var _a, _b;
2748
2744
  if (n1 === n2) {
2749
2745
  return;
@@ -2764,7 +2760,7 @@ var LWC = (function (exports) {
2764
2760
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2765
2761
  break;
2766
2762
  case 3 /* VNodeType.CustomElement */:
2767
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2763
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2768
2764
  break;
2769
2765
  }
2770
2766
  }
@@ -2886,22 +2882,32 @@ var LWC = (function (exports) {
2886
2882
  appendVM(vm);
2887
2883
  }
2888
2884
  }
2889
- function patchCustomElement(n1, n2, renderer) {
2890
- const elm = (n2.elm = n1.elm);
2891
- const vm = (n2.vm = n1.vm);
2892
- patchElementPropsAndAttrs$1(n1, n2, renderer);
2893
- if (!isUndefined$1(vm)) {
2894
- // in fallback mode, the allocation will always set children to
2895
- // empty and delegate the real allocation to the slot elements
2896
- allocateChildren(n2, vm);
2885
+ function patchCustomElement(n1, n2, parent, renderer) {
2886
+ if (n1.ctor !== n2.ctor) {
2887
+ // If the constructor, unmount the current component and mount a new one using the new
2888
+ // constructor.
2889
+ const anchor = renderer.nextSibling(n1.elm);
2890
+ unmount(n1, parent, renderer, true);
2891
+ mountCustomElement(n2, parent, anchor, renderer);
2897
2892
  }
2898
- // in fallback mode, the children will be always empty, so, nothing
2899
- // will happen, but in native, it does allocate the light dom
2900
- patchChildren(n1.children, n2.children, elm, renderer);
2901
- if (!isUndefined$1(vm)) {
2902
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
2903
- // this is important to preserve the top to bottom synchronous rendering phase.
2904
- rerenderVM(vm);
2893
+ else {
2894
+ // Otherwise patch the existing component with new props/attrs/etc.
2895
+ const elm = (n2.elm = n1.elm);
2896
+ const vm = (n2.vm = n1.vm);
2897
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
2898
+ if (!isUndefined$1(vm)) {
2899
+ // in fallback mode, the allocation will always set children to
2900
+ // empty and delegate the real allocation to the slot elements
2901
+ allocateChildren(n2, vm);
2902
+ }
2903
+ // in fallback mode, the children will be always empty, so, nothing
2904
+ // will happen, but in native, it does allocate the light dom
2905
+ patchChildren(n1.children, n2.children, elm, renderer);
2906
+ if (!isUndefined$1(vm)) {
2907
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
2908
+ // this is important to preserve the top to bottom synchronous rendering phase.
2909
+ rerenderVM(vm);
2910
+ }
2905
2911
  }
2906
2912
  }
2907
2913
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -3139,25 +3145,25 @@ var LWC = (function (exports) {
3139
3145
  newEndVnode = newCh[--newEndIdx];
3140
3146
  }
3141
3147
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
3142
- patch(oldStartVnode, newStartVnode, renderer);
3148
+ patch(oldStartVnode, newStartVnode, parent, renderer);
3143
3149
  oldStartVnode = oldCh[++oldStartIdx];
3144
3150
  newStartVnode = newCh[++newStartIdx];
3145
3151
  }
3146
3152
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
3147
- patch(oldEndVnode, newEndVnode, renderer);
3153
+ patch(oldEndVnode, newEndVnode, parent, renderer);
3148
3154
  oldEndVnode = oldCh[--oldEndIdx];
3149
3155
  newEndVnode = newCh[--newEndIdx];
3150
3156
  }
3151
3157
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
3152
3158
  // Vnode moved right
3153
- patch(oldStartVnode, newEndVnode, renderer);
3159
+ patch(oldStartVnode, newEndVnode, parent, renderer);
3154
3160
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3155
3161
  oldStartVnode = oldCh[++oldStartIdx];
3156
3162
  newEndVnode = newCh[--newEndIdx];
3157
3163
  }
3158
3164
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
3159
3165
  // Vnode moved left
3160
- patch(oldEndVnode, newStartVnode, renderer);
3166
+ patch(oldEndVnode, newStartVnode, parent, renderer);
3161
3167
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3162
3168
  oldEndVnode = oldCh[--oldEndIdx];
3163
3169
  newStartVnode = newCh[++newStartIdx];
@@ -3180,7 +3186,7 @@ var LWC = (function (exports) {
3180
3186
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3181
3187
  }
3182
3188
  else {
3183
- patch(elmToMove, newStartVnode, renderer);
3189
+ patch(elmToMove, newStartVnode, parent, renderer);
3184
3190
  // Delete the old child, but copy the array since it is read-only.
3185
3191
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3186
3192
  // so we only care about the `oldCh` object inside this function.
@@ -3240,7 +3246,7 @@ var LWC = (function (exports) {
3240
3246
  if (isVNode(n1)) {
3241
3247
  if (isVNode(n2)) {
3242
3248
  // both vnodes are equivalent, and we just need to patch them
3243
- patch(n1, n2, renderer);
3249
+ patch(n1, n2, parent, renderer);
3244
3250
  anchor = n2.elm;
3245
3251
  }
3246
3252
  else {
@@ -3469,13 +3475,6 @@ var LWC = (function (exports) {
3469
3475
  }
3470
3476
  return url;
3471
3477
  }
3472
- /**
3473
- * Map to store an index value assigned to any dynamic component reference ingested
3474
- * by dc() api. This allows us to generate a unique unique per template per dynamic
3475
- * component reference to avoid diffing algo mismatches.
3476
- */
3477
- const DynamicImportedComponentMap = new Map();
3478
- let dynamicImportedComponentCounter = 0;
3479
3478
  /**
3480
3479
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
3481
3480
  */
@@ -3487,18 +3486,7 @@ var LWC = (function (exports) {
3487
3486
  if (!isComponentConstructor(Ctor)) {
3488
3487
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
3489
3488
  }
3490
- let idx = DynamicImportedComponentMap.get(Ctor);
3491
- if (isUndefined$1(idx)) {
3492
- idx = dynamicImportedComponentCounter++;
3493
- DynamicImportedComponentMap.set(Ctor, idx);
3494
- }
3495
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
3496
- // to identify different constructors as vnodes with different keys to avoid reusing the
3497
- // element used for previous constructors.
3498
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
3499
- // hoisting optimization.
3500
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
3501
- return c(sel, Ctor, newData, children);
3489
+ return c(sel, Ctor, data, children);
3502
3490
  }
3503
3491
  /**
3504
3492
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4218,16 +4206,9 @@ var LWC = (function (exports) {
4218
4206
  const {
4219
4207
  def: {
4220
4208
  renderedCallback
4221
- },
4222
- renderer: {
4223
- ssr
4224
4209
  }
4225
4210
  } = vm;
4226
4211
 
4227
- if (isTrue(ssr)) {
4228
- return;
4229
- }
4230
-
4231
4212
  const {
4232
4213
  rendered
4233
4214
  } = Services;
@@ -4468,13 +4449,7 @@ var LWC = (function (exports) {
4468
4449
  vm.velements = EmptyArray;
4469
4450
  }
4470
4451
  function scheduleRehydration(vm) {
4471
- const {
4472
- renderer: {
4473
- ssr
4474
- }
4475
- } = vm;
4476
-
4477
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
4452
+ if (isTrue(vm.isScheduled)) {
4478
4453
  return;
4479
4454
  }
4480
4455
 
@@ -4564,15 +4539,8 @@ var LWC = (function (exports) {
4564
4539
  }
4565
4540
 
4566
4541
  function createFieldDataCallback(vm, name) {
4567
- const {
4568
- cmpFields
4569
- } = vm;
4570
4542
  return value => {
4571
- if (value !== vm.cmpFields[name]) {
4572
- // storing the value in the underlying storage
4573
- cmpFields[name] = value;
4574
- componentValueMutated(vm, name);
4575
- }
4543
+ updateComponentValue(vm, name, value);
4576
4544
  };
4577
4545
  }
4578
4546
 
@@ -5227,7 +5195,7 @@ var LWC = (function (exports) {
5227
5195
  }
5228
5196
  return ctor;
5229
5197
  }
5230
- /* version: 2.22.0 */
5198
+ /* version: 2.23.0 */
5231
5199
 
5232
5200
  /*
5233
5201
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5490,14 +5458,6 @@ var LWC = (function (exports) {
5490
5458
  };
5491
5459
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5492
5460
  }
5493
- let hydrating = false;
5494
- function setIsHydrating(value) {
5495
- hydrating = value;
5496
- }
5497
- const ssr = false;
5498
- function isHydrating() {
5499
- return hydrating;
5500
- }
5501
5461
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
5502
5462
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
5503
5463
  function cloneNode(node, deep) {
@@ -5524,15 +5484,11 @@ var LWC = (function (exports) {
5524
5484
  return node.nextSibling;
5525
5485
  }
5526
5486
  function attachShadow(element, options) {
5527
- // `hydrating` will be true in two cases:
5487
+ // `shadowRoot` will be non-null in two cases:
5528
5488
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
5529
5489
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
5530
- // root component with customeElement.define('c-app', Ctor)
5531
- //
5532
- // The second case can be treated as a failed hydration with nominal impact
5533
- // to performance. However, because <c-app> won't have a <template shadowroot>
5534
- // declarative child, `element.shadowRoot` is `null`.
5535
- if (hydrating && element.shadowRoot) {
5490
+ // root component with customElement.define('c-app', Ctor)
5491
+ if (!isNull(element.shadowRoot)) {
5536
5492
  return element.shadowRoot;
5537
5493
  }
5538
5494
  return element.attachShadow(options);
@@ -5622,11 +5578,9 @@ var LWC = (function (exports) {
5622
5578
  }
5623
5579
  const HTMLElementExported = HTMLElementConstructor;
5624
5580
  const renderer = {
5625
- ssr,
5626
5581
  isNativeShadowDefined,
5627
5582
  isSyntheticShadowDefined,
5628
5583
  HTMLElementExported,
5629
- isHydrating,
5630
5584
  insert,
5631
5585
  remove,
5632
5586
  cloneNode,
@@ -5712,13 +5666,8 @@ var LWC = (function (exports) {
5712
5666
  return;
5713
5667
  }
5714
5668
  try {
5715
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
5716
- // and uses the same algo to create the stylesheets as in SSR.
5717
- setIsHydrating(true);
5718
5669
  const vm = createVMWithProps(element, Ctor, props);
5719
5670
  hydrateRoot(vm);
5720
- // set it back since now we finished hydration.
5721
- setIsHydrating(false);
5722
5671
  }
5723
5672
  catch (e) {
5724
5673
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -5729,13 +5678,8 @@ var LWC = (function (exports) {
5729
5678
  resetShadowRootAndLightDom(element, Ctor);
5730
5679
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
5731
5680
  createVMWithProps(element, Ctor, props);
5732
- setIsHydrating(false);
5733
5681
  connectRootElement(element);
5734
5682
  }
5735
- finally {
5736
- // in case there's an error during recovery
5737
- setIsHydrating(false);
5738
- }
5739
5683
  }
5740
5684
 
5741
5685
  /*
@@ -5952,7 +5896,7 @@ var LWC = (function (exports) {
5952
5896
  });
5953
5897
  freeze(LightningElement);
5954
5898
  seal(LightningElement.prototype);
5955
- /* version: 2.22.0 */
5899
+ /* version: 2.23.0 */
5956
5900
 
5957
5901
  exports.LightningElement = LightningElement;
5958
5902
  exports.__unstable__ProfilerControl = profilerControl;