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
@@ -294,7 +294,7 @@
294
294
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
295
295
  return attributeName;
296
296
  }
297
- /** version: 2.22.0 */
297
+ /** version: 2.23.0 */
298
298
 
299
299
  /*
300
300
  * Copyright (c) 2018, salesforce.com, inc.
@@ -862,6 +862,14 @@
862
862
  }
863
863
  });
864
864
 
865
+ function updateComponentValue(vm, key, newValue) {
866
+ const { cmpFields } = vm;
867
+ if (newValue !== cmpFields[key]) {
868
+ cmpFields[key] = newValue;
869
+ componentValueMutated(vm, key);
870
+ }
871
+ }
872
+
865
873
  /**
866
874
  * Copyright (C) 2017 salesforce.com, inc.
867
875
  */
@@ -1345,10 +1353,7 @@
1345
1353
  },
1346
1354
  set(newValue) {
1347
1355
  const vm = getAssociatedVM(this);
1348
- if (newValue !== vm.cmpProps[propName]) {
1349
- vm.cmpProps[propName] = newValue;
1350
- componentValueMutated(vm, propName);
1351
- }
1356
+ updateComponentValue(vm, propName, newValue);
1352
1357
  return set.call(vm.elm, newValue);
1353
1358
  },
1354
1359
  };
@@ -1577,10 +1582,7 @@
1577
1582
  },
1578
1583
  set(newValue) {
1579
1584
  const vm = getAssociatedVM(this);
1580
- if (newValue !== vm.cmpFields[key]) {
1581
- vm.cmpFields[key] = newValue;
1582
- componentValueMutated(vm, key);
1583
- }
1585
+ updateComponentValue(vm, key, newValue);
1584
1586
  },
1585
1587
  enumerable: true,
1586
1588
  configurable: true,
@@ -1732,10 +1734,7 @@
1732
1734
  set(newValue) {
1733
1735
  const vm = getAssociatedVM(this);
1734
1736
  const reactiveOrAnyValue = getReactiveProxy(newValue);
1735
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1736
- vm.cmpFields[key] = reactiveOrAnyValue;
1737
- componentValueMutated(vm, key);
1738
- }
1737
+ updateComponentValue(vm, key, reactiveOrAnyValue);
1739
1738
  },
1740
1739
  enumerable: true,
1741
1740
  configurable: true,
@@ -1771,10 +1770,7 @@
1771
1770
  * letting the author to do the wrong thing, but it will keep our
1772
1771
  * system to be backward compatible.
1773
1772
  */
1774
- if (value !== vm.cmpFields[key]) {
1775
- vm.cmpFields[key] = value;
1776
- componentValueMutated(vm, key);
1777
- }
1773
+ updateComponentValue(vm, key, value);
1778
1774
  },
1779
1775
  enumerable: true,
1780
1776
  configurable: true,
@@ -2443,13 +2439,13 @@
2443
2439
  return owner;
2444
2440
  }
2445
2441
  function createStylesheet(vm, stylesheets) {
2446
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
2442
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
2447
2443
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
2448
2444
  for (let i = 0; i < stylesheets.length; i++) {
2449
2445
  insertStylesheet(stylesheets[i]);
2450
2446
  }
2451
2447
  }
2452
- else if (ssr || vm.hydrated) {
2448
+ else if (vm.hydrated) {
2453
2449
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
2454
2450
  // This works in the client, because the stylesheets are created, and cached in the VM
2455
2451
  // the first time the VM renders.
@@ -2746,7 +2742,7 @@
2746
2742
  updateStaticChildren(c1, c2, parent, renderer);
2747
2743
  }
2748
2744
  }
2749
- function patch(n1, n2, renderer) {
2745
+ function patch(n1, n2, parent, renderer) {
2750
2746
  var _a, _b;
2751
2747
  if (n1 === n2) {
2752
2748
  return;
@@ -2767,7 +2763,7 @@
2767
2763
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2768
2764
  break;
2769
2765
  case 3 /* VNodeType.CustomElement */:
2770
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2766
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2771
2767
  break;
2772
2768
  }
2773
2769
  }
@@ -2889,22 +2885,32 @@
2889
2885
  appendVM(vm);
2890
2886
  }
2891
2887
  }
2892
- function patchCustomElement(n1, n2, renderer) {
2893
- const elm = (n2.elm = n1.elm);
2894
- const vm = (n2.vm = n1.vm);
2895
- patchElementPropsAndAttrs$1(n1, n2, renderer);
2896
- if (!isUndefined$1(vm)) {
2897
- // in fallback mode, the allocation will always set children to
2898
- // empty and delegate the real allocation to the slot elements
2899
- allocateChildren(n2, vm);
2888
+ function patchCustomElement(n1, n2, parent, renderer) {
2889
+ if (n1.ctor !== n2.ctor) {
2890
+ // If the constructor, unmount the current component and mount a new one using the new
2891
+ // constructor.
2892
+ const anchor = renderer.nextSibling(n1.elm);
2893
+ unmount(n1, parent, renderer, true);
2894
+ mountCustomElement(n2, parent, anchor, renderer);
2900
2895
  }
2901
- // in fallback mode, the children will be always empty, so, nothing
2902
- // will happen, but in native, it does allocate the light dom
2903
- patchChildren(n1.children, n2.children, elm, renderer);
2904
- if (!isUndefined$1(vm)) {
2905
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
2906
- // this is important to preserve the top to bottom synchronous rendering phase.
2907
- rerenderVM(vm);
2896
+ else {
2897
+ // Otherwise patch the existing component with new props/attrs/etc.
2898
+ const elm = (n2.elm = n1.elm);
2899
+ const vm = (n2.vm = n1.vm);
2900
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
2901
+ if (!isUndefined$1(vm)) {
2902
+ // in fallback mode, the allocation will always set children to
2903
+ // empty and delegate the real allocation to the slot elements
2904
+ allocateChildren(n2, vm);
2905
+ }
2906
+ // in fallback mode, the children will be always empty, so, nothing
2907
+ // will happen, but in native, it does allocate the light dom
2908
+ patchChildren(n1.children, n2.children, elm, renderer);
2909
+ if (!isUndefined$1(vm)) {
2910
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
2911
+ // this is important to preserve the top to bottom synchronous rendering phase.
2912
+ rerenderVM(vm);
2913
+ }
2908
2914
  }
2909
2915
  }
2910
2916
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -3142,25 +3148,25 @@
3142
3148
  newEndVnode = newCh[--newEndIdx];
3143
3149
  }
3144
3150
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
3145
- patch(oldStartVnode, newStartVnode, renderer);
3151
+ patch(oldStartVnode, newStartVnode, parent, renderer);
3146
3152
  oldStartVnode = oldCh[++oldStartIdx];
3147
3153
  newStartVnode = newCh[++newStartIdx];
3148
3154
  }
3149
3155
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
3150
- patch(oldEndVnode, newEndVnode, renderer);
3156
+ patch(oldEndVnode, newEndVnode, parent, renderer);
3151
3157
  oldEndVnode = oldCh[--oldEndIdx];
3152
3158
  newEndVnode = newCh[--newEndIdx];
3153
3159
  }
3154
3160
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
3155
3161
  // Vnode moved right
3156
- patch(oldStartVnode, newEndVnode, renderer);
3162
+ patch(oldStartVnode, newEndVnode, parent, renderer);
3157
3163
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3158
3164
  oldStartVnode = oldCh[++oldStartIdx];
3159
3165
  newEndVnode = newCh[--newEndIdx];
3160
3166
  }
3161
3167
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
3162
3168
  // Vnode moved left
3163
- patch(oldEndVnode, newStartVnode, renderer);
3169
+ patch(oldEndVnode, newStartVnode, parent, renderer);
3164
3170
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3165
3171
  oldEndVnode = oldCh[--oldEndIdx];
3166
3172
  newStartVnode = newCh[++newStartIdx];
@@ -3183,7 +3189,7 @@
3183
3189
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3184
3190
  }
3185
3191
  else {
3186
- patch(elmToMove, newStartVnode, renderer);
3192
+ patch(elmToMove, newStartVnode, parent, renderer);
3187
3193
  // Delete the old child, but copy the array since it is read-only.
3188
3194
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3189
3195
  // so we only care about the `oldCh` object inside this function.
@@ -3243,7 +3249,7 @@
3243
3249
  if (isVNode(n1)) {
3244
3250
  if (isVNode(n2)) {
3245
3251
  // both vnodes are equivalent, and we just need to patch them
3246
- patch(n1, n2, renderer);
3252
+ patch(n1, n2, parent, renderer);
3247
3253
  anchor = n2.elm;
3248
3254
  }
3249
3255
  else {
@@ -3472,13 +3478,6 @@
3472
3478
  }
3473
3479
  return url;
3474
3480
  }
3475
- /**
3476
- * Map to store an index value assigned to any dynamic component reference ingested
3477
- * by dc() api. This allows us to generate a unique unique per template per dynamic
3478
- * component reference to avoid diffing algo mismatches.
3479
- */
3480
- const DynamicImportedComponentMap = new Map();
3481
- let dynamicImportedComponentCounter = 0;
3482
3481
  /**
3483
3482
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
3484
3483
  */
@@ -3490,18 +3489,7 @@
3490
3489
  if (!isComponentConstructor(Ctor)) {
3491
3490
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
3492
3491
  }
3493
- let idx = DynamicImportedComponentMap.get(Ctor);
3494
- if (isUndefined$1(idx)) {
3495
- idx = dynamicImportedComponentCounter++;
3496
- DynamicImportedComponentMap.set(Ctor, idx);
3497
- }
3498
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
3499
- // to identify different constructors as vnodes with different keys to avoid reusing the
3500
- // element used for previous constructors.
3501
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
3502
- // hoisting optimization.
3503
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
3504
- return c(sel, Ctor, newData, children);
3492
+ return c(sel, Ctor, data, children);
3505
3493
  }
3506
3494
  /**
3507
3495
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4221,16 +4209,9 @@
4221
4209
  const {
4222
4210
  def: {
4223
4211
  renderedCallback
4224
- },
4225
- renderer: {
4226
- ssr
4227
4212
  }
4228
4213
  } = vm;
4229
4214
 
4230
- if (isTrue(ssr)) {
4231
- return;
4232
- }
4233
-
4234
4215
  const {
4235
4216
  rendered
4236
4217
  } = Services;
@@ -4471,13 +4452,7 @@
4471
4452
  vm.velements = EmptyArray;
4472
4453
  }
4473
4454
  function scheduleRehydration(vm) {
4474
- const {
4475
- renderer: {
4476
- ssr
4477
- }
4478
- } = vm;
4479
-
4480
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
4455
+ if (isTrue(vm.isScheduled)) {
4481
4456
  return;
4482
4457
  }
4483
4458
 
@@ -4567,15 +4542,8 @@
4567
4542
  }
4568
4543
 
4569
4544
  function createFieldDataCallback(vm, name) {
4570
- const {
4571
- cmpFields
4572
- } = vm;
4573
4545
  return value => {
4574
- if (value !== vm.cmpFields[name]) {
4575
- // storing the value in the underlying storage
4576
- cmpFields[name] = value;
4577
- componentValueMutated(vm, name);
4578
- }
4546
+ updateComponentValue(vm, name, value);
4579
4547
  };
4580
4548
  }
4581
4549
 
@@ -5230,7 +5198,7 @@
5230
5198
  }
5231
5199
  return ctor;
5232
5200
  }
5233
- /* version: 2.22.0 */
5201
+ /* version: 2.23.0 */
5234
5202
 
5235
5203
  /*
5236
5204
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5493,14 +5461,6 @@
5493
5461
  };
5494
5462
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5495
5463
  }
5496
- let hydrating = false;
5497
- function setIsHydrating(value) {
5498
- hydrating = value;
5499
- }
5500
- const ssr = false;
5501
- function isHydrating() {
5502
- return hydrating;
5503
- }
5504
5464
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
5505
5465
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
5506
5466
  function cloneNode(node, deep) {
@@ -5527,15 +5487,11 @@
5527
5487
  return node.nextSibling;
5528
5488
  }
5529
5489
  function attachShadow(element, options) {
5530
- // `hydrating` will be true in two cases:
5490
+ // `shadowRoot` will be non-null in two cases:
5531
5491
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
5532
5492
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
5533
- // root component with customeElement.define('c-app', Ctor)
5534
- //
5535
- // The second case can be treated as a failed hydration with nominal impact
5536
- // to performance. However, because <c-app> won't have a <template shadowroot>
5537
- // declarative child, `element.shadowRoot` is `null`.
5538
- if (hydrating && element.shadowRoot) {
5493
+ // root component with customElement.define('c-app', Ctor)
5494
+ if (!isNull(element.shadowRoot)) {
5539
5495
  return element.shadowRoot;
5540
5496
  }
5541
5497
  return element.attachShadow(options);
@@ -5625,11 +5581,9 @@
5625
5581
  }
5626
5582
  const HTMLElementExported = HTMLElementConstructor;
5627
5583
  const renderer = {
5628
- ssr,
5629
5584
  isNativeShadowDefined,
5630
5585
  isSyntheticShadowDefined,
5631
5586
  HTMLElementExported,
5632
- isHydrating,
5633
5587
  insert,
5634
5588
  remove,
5635
5589
  cloneNode,
@@ -5715,13 +5669,8 @@
5715
5669
  return;
5716
5670
  }
5717
5671
  try {
5718
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
5719
- // and uses the same algo to create the stylesheets as in SSR.
5720
- setIsHydrating(true);
5721
5672
  const vm = createVMWithProps(element, Ctor, props);
5722
5673
  hydrateRoot(vm);
5723
- // set it back since now we finished hydration.
5724
- setIsHydrating(false);
5725
5674
  }
5726
5675
  catch (e) {
5727
5676
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -5732,13 +5681,8 @@
5732
5681
  resetShadowRootAndLightDom(element, Ctor);
5733
5682
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
5734
5683
  createVMWithProps(element, Ctor, props);
5735
- setIsHydrating(false);
5736
5684
  connectRootElement(element);
5737
5685
  }
5738
- finally {
5739
- // in case there's an error during recovery
5740
- setIsHydrating(false);
5741
- }
5742
5686
  }
5743
5687
 
5744
5688
  /*
@@ -5955,7 +5899,7 @@
5955
5899
  });
5956
5900
  freeze(LightningElement);
5957
5901
  seal(LightningElement.prototype);
5958
- /* version: 2.22.0 */
5902
+ /* version: 2.23.0 */
5959
5903
 
5960
5904
  exports.LightningElement = LightningElement;
5961
5905
  exports.__unstable__ProfilerControl = profilerControl;