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
@@ -346,7 +346,7 @@ var LWC = (function (exports) {
346
346
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
347
347
  return attributeName;
348
348
  }
349
- /** version: 2.22.0 */
349
+ /** version: 2.23.0 */
350
350
 
351
351
  /*
352
352
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1016,6 +1016,15 @@ var LWC = (function (exports) {
1016
1016
  HTMLElementOriginalDescriptors[propName] = descriptor;
1017
1017
  }
1018
1018
  });
1019
+
1020
+ function updateComponentValue(vm, key, newValue) {
1021
+ var cmpFields = vm.cmpFields;
1022
+
1023
+ if (newValue !== cmpFields[key]) {
1024
+ cmpFields[key] = newValue;
1025
+ componentValueMutated(vm, key);
1026
+ }
1027
+ }
1019
1028
  /**
1020
1029
  * Copyright (C) 2017 salesforce.com, inc.
1021
1030
  */
@@ -1746,11 +1755,7 @@ var LWC = (function (exports) {
1746
1755
  set: function set(newValue) {
1747
1756
  var vm = getAssociatedVM(this);
1748
1757
 
1749
- if (newValue !== vm.cmpProps[propName]) {
1750
- vm.cmpProps[propName] = newValue;
1751
- componentValueMutated(vm, propName);
1752
- }
1753
-
1758
+ updateComponentValue(vm, propName, newValue);
1754
1759
  return _set.call(vm.elm, newValue);
1755
1760
  }
1756
1761
  };
@@ -2038,11 +2043,7 @@ var LWC = (function (exports) {
2038
2043
  },
2039
2044
  set: function set(newValue) {
2040
2045
  var vm = getAssociatedVM(this);
2041
-
2042
- if (newValue !== vm.cmpFields[key]) {
2043
- vm.cmpFields[key] = newValue;
2044
- componentValueMutated(vm, key);
2045
- }
2046
+ updateComponentValue(vm, key, newValue);
2046
2047
  },
2047
2048
  enumerable: true,
2048
2049
  configurable: true
@@ -2220,11 +2221,7 @@ var LWC = (function (exports) {
2220
2221
  var vm = getAssociatedVM(this);
2221
2222
 
2222
2223
  var reactiveOrAnyValue = getReactiveProxy(newValue);
2223
-
2224
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2225
- vm.cmpFields[key] = reactiveOrAnyValue;
2226
- componentValueMutated(vm, key);
2227
- }
2224
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2228
2225
  },
2229
2226
  enumerable: true,
2230
2227
  configurable: true
@@ -2265,10 +2262,7 @@ var LWC = (function (exports) {
2265
2262
  * system to be backward compatible.
2266
2263
  */
2267
2264
 
2268
- if (value !== vm.cmpFields[key]) {
2269
- vm.cmpFields[key] = value;
2270
- componentValueMutated(vm, key);
2271
- }
2265
+ updateComponentValue(vm, key, value);
2272
2266
  },
2273
2267
  enumerable: true,
2274
2268
  configurable: true
@@ -3134,9 +3128,7 @@ var LWC = (function (exports) {
3134
3128
  function createStylesheet(vm, stylesheets) {
3135
3129
  var renderMode = vm.renderMode,
3136
3130
  shadowMode = vm.shadowMode,
3137
- _vm$renderer2 = vm.renderer,
3138
- ssr = _vm$renderer2.ssr,
3139
- insertStylesheet = _vm$renderer2.insertStylesheet;
3131
+ insertStylesheet = vm.renderer.insertStylesheet;
3140
3132
 
3141
3133
  if (renderMode === 1
3142
3134
  /* RenderMode.Shadow */
@@ -3146,7 +3138,7 @@ var LWC = (function (exports) {
3146
3138
  for (var _i12 = 0; _i12 < stylesheets.length; _i12++) {
3147
3139
  insertStylesheet(stylesheets[_i12]);
3148
3140
  }
3149
- } else if (ssr || vm.hydrated) {
3141
+ } else if (vm.hydrated) {
3150
3142
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3151
3143
  // This works in the client, because the stylesheets are created, and cached in the VM
3152
3144
  // the first time the VM renders.
@@ -3527,7 +3519,7 @@ var LWC = (function (exports) {
3527
3519
  }
3528
3520
  }
3529
3521
 
3530
- function patch(n1, n2, renderer) {
3522
+ function patch(n1, n2, parent, renderer) {
3531
3523
  var _a, _b;
3532
3524
 
3533
3525
  if (n1 === n2) {
@@ -3564,7 +3556,7 @@ var LWC = (function (exports) {
3564
3556
  case 3
3565
3557
  /* VNodeType.CustomElement */
3566
3558
  :
3567
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3559
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3568
3560
  break;
3569
3561
  }
3570
3562
  }
@@ -3729,25 +3721,34 @@ var LWC = (function (exports) {
3729
3721
  }
3730
3722
  }
3731
3723
 
3732
- function patchCustomElement(n1, n2, renderer) {
3733
- var elm = n2.elm = n1.elm;
3734
- var vm = n2.vm = n1.vm;
3735
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3724
+ function patchCustomElement(n1, n2, parent, renderer) {
3725
+ if (n1.ctor !== n2.ctor) {
3726
+ // If the constructor, unmount the current component and mount a new one using the new
3727
+ // constructor.
3728
+ var anchor = renderer.nextSibling(n1.elm);
3729
+ unmount(n1, parent, renderer, true);
3730
+ mountCustomElement(n2, parent, anchor, renderer);
3731
+ } else {
3732
+ // Otherwise patch the existing component with new props/attrs/etc.
3733
+ var elm = n2.elm = n1.elm;
3734
+ var vm = n2.vm = n1.vm;
3735
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3736
3736
 
3737
- if (!isUndefined$1(vm)) {
3738
- // in fallback mode, the allocation will always set children to
3739
- // empty and delegate the real allocation to the slot elements
3740
- allocateChildren(n2, vm);
3741
- } // in fallback mode, the children will be always empty, so, nothing
3742
- // will happen, but in native, it does allocate the light dom
3737
+ if (!isUndefined$1(vm)) {
3738
+ // in fallback mode, the allocation will always set children to
3739
+ // empty and delegate the real allocation to the slot elements
3740
+ allocateChildren(n2, vm);
3741
+ } // in fallback mode, the children will be always empty, so, nothing
3742
+ // will happen, but in native, it does allocate the light dom
3743
3743
 
3744
3744
 
3745
- patchChildren(n1.children, n2.children, elm, renderer);
3745
+ patchChildren(n1.children, n2.children, elm, renderer);
3746
3746
 
3747
- if (!isUndefined$1(vm)) {
3748
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3749
- // this is important to preserve the top to bottom synchronous rendering phase.
3750
- rerenderVM(vm);
3747
+ if (!isUndefined$1(vm)) {
3748
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3749
+ // this is important to preserve the top to bottom synchronous rendering phase.
3750
+ rerenderVM(vm);
3751
+ }
3751
3752
  }
3752
3753
  }
3753
3754
 
@@ -4071,22 +4072,22 @@ var LWC = (function (exports) {
4071
4072
  } else if (!isVNode(newEndVnode)) {
4072
4073
  newEndVnode = newCh[--newEndIdx];
4073
4074
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4074
- patch(oldStartVnode, newStartVnode, renderer);
4075
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4075
4076
  oldStartVnode = oldCh[++oldStartIdx];
4076
4077
  newStartVnode = newCh[++newStartIdx];
4077
4078
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4078
- patch(oldEndVnode, newEndVnode, renderer);
4079
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4079
4080
  oldEndVnode = oldCh[--oldEndIdx];
4080
4081
  newEndVnode = newCh[--newEndIdx];
4081
4082
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4082
4083
  // Vnode moved right
4083
- patch(oldStartVnode, newEndVnode, renderer);
4084
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4084
4085
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4085
4086
  oldStartVnode = oldCh[++oldStartIdx];
4086
4087
  newEndVnode = newCh[--newEndIdx];
4087
4088
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4088
4089
  // Vnode moved left
4089
- patch(oldEndVnode, newStartVnode, renderer);
4090
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4090
4091
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4091
4092
  oldEndVnode = oldCh[--oldEndIdx];
4092
4093
  newStartVnode = newCh[++newStartIdx];
@@ -4109,7 +4110,7 @@ var LWC = (function (exports) {
4109
4110
  // New element
4110
4111
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4111
4112
  } else {
4112
- patch(elmToMove, newStartVnode, renderer); // Delete the old child, but copy the array since it is read-only.
4113
+ patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
4113
4114
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4114
4115
  // so we only care about the `oldCh` object inside this function.
4115
4116
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -4179,7 +4180,7 @@ var LWC = (function (exports) {
4179
4180
  if (isVNode(n1)) {
4180
4181
  if (isVNode(n2)) {
4181
4182
  // both vnodes are equivalent, and we just need to patch them
4182
- patch(n1, n2, renderer);
4183
+ patch(n1, n2, parent, renderer);
4183
4184
  anchor = n2.elm;
4184
4185
  } else {
4185
4186
  // removing the old vnode since the new one is null
@@ -4480,19 +4481,11 @@ var LWC = (function (exports) {
4480
4481
 
4481
4482
  return url;
4482
4483
  }
4483
- /**
4484
- * Map to store an index value assigned to any dynamic component reference ingested
4485
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4486
- * component reference to avoid diffing algo mismatches.
4487
- */
4488
-
4489
-
4490
- var DynamicImportedComponentMap = new Map();
4491
- var dynamicImportedComponentCounter = 0;
4492
4484
  /**
4493
4485
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4494
4486
  */
4495
4487
 
4488
+
4496
4489
  function dc(sel, Ctor, data) {
4497
4490
  var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
4498
4491
 
@@ -4505,22 +4498,7 @@ var LWC = (function (exports) {
4505
4498
  throw new Error("Invalid LWC Constructor ".concat(toString$1(Ctor), " for custom element <").concat(sel, ">."));
4506
4499
  }
4507
4500
 
4508
- var idx = DynamicImportedComponentMap.get(Ctor);
4509
-
4510
- if (isUndefined$1(idx)) {
4511
- idx = dynamicImportedComponentCounter++;
4512
- DynamicImportedComponentMap.set(Ctor, idx);
4513
- } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4514
- // to identify different constructors as vnodes with different keys to avoid reusing the
4515
- // element used for previous constructors.
4516
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4517
- // hoisting optimization.
4518
-
4519
-
4520
- var newData = Object.assign(Object.assign({}, data), {
4521
- key: "dc:".concat(idx, ":").concat(data.key)
4522
- });
4523
- return c(sel, Ctor, newData, children);
4501
+ return c(sel, Ctor, data, children);
4524
4502
  }
4525
4503
  /**
4526
4504
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5360,13 +5338,7 @@ var LWC = (function (exports) {
5360
5338
  }
5361
5339
 
5362
5340
  function runRenderedCallback(vm) {
5363
- var renderedCallback = vm.def.renderedCallback,
5364
- ssr = vm.renderer.ssr;
5365
-
5366
- if (isTrue(ssr)) {
5367
- return;
5368
- }
5369
-
5341
+ var renderedCallback = vm.def.renderedCallback;
5370
5342
  var rendered = Services.rendered;
5371
5343
 
5372
5344
  if (rendered) {
@@ -5589,9 +5561,7 @@ var LWC = (function (exports) {
5589
5561
  }
5590
5562
 
5591
5563
  function scheduleRehydration(vm) {
5592
- var ssr = vm.renderer.ssr;
5593
-
5594
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5564
+ if (isTrue(vm.isScheduled)) {
5595
5565
  return;
5596
5566
  }
5597
5567
 
@@ -5693,13 +5663,8 @@ var LWC = (function (exports) {
5693
5663
  }( /*#__PURE__*/_wrapNativeSuper(CustomEvent));
5694
5664
 
5695
5665
  function createFieldDataCallback(vm, name) {
5696
- var cmpFields = vm.cmpFields;
5697
5666
  return function (value) {
5698
- if (value !== vm.cmpFields[name]) {
5699
- // storing the value in the underlying storage
5700
- cmpFields[name] = value;
5701
- componentValueMutated(vm, name);
5702
- }
5667
+ updateComponentValue(vm, name, value);
5703
5668
  };
5704
5669
  }
5705
5670
 
@@ -6489,7 +6454,7 @@ var LWC = (function (exports) {
6489
6454
 
6490
6455
  return ctor;
6491
6456
  }
6492
- /* version: 2.22.0 */
6457
+ /* version: 2.23.0 */
6493
6458
 
6494
6459
  /*
6495
6460
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6808,18 +6773,6 @@ var LWC = (function (exports) {
6808
6773
  HTMLElementConstructor.prototype = HTMLElement.prototype;
6809
6774
  }
6810
6775
 
6811
- var hydrating = false;
6812
-
6813
- function setIsHydrating(value) {
6814
- hydrating = value;
6815
- }
6816
-
6817
- var ssr = false;
6818
-
6819
- function isHydrating() {
6820
- return hydrating;
6821
- }
6822
-
6823
6776
  var isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
6824
6777
  var isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
6825
6778
 
@@ -6852,15 +6805,11 @@ var LWC = (function (exports) {
6852
6805
  }
6853
6806
 
6854
6807
  function attachShadow(element, options) {
6855
- // `hydrating` will be true in two cases:
6808
+ // `shadowRoot` will be non-null in two cases:
6856
6809
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
6857
6810
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
6858
- // root component with customeElement.define('c-app', Ctor)
6859
- //
6860
- // The second case can be treated as a failed hydration with nominal impact
6861
- // to performance. However, because <c-app> won't have a <template shadowroot>
6862
- // declarative child, `element.shadowRoot` is `null`.
6863
- if (hydrating && element.shadowRoot) {
6811
+ // root component with customElement.define('c-app', Ctor)
6812
+ if (!isNull(element.shadowRoot)) {
6864
6813
  return element.shadowRoot;
6865
6814
  }
6866
6815
 
@@ -6972,11 +6921,9 @@ var LWC = (function (exports) {
6972
6921
 
6973
6922
  var HTMLElementExported = HTMLElementConstructor;
6974
6923
  var renderer = {
6975
- ssr: ssr,
6976
6924
  isNativeShadowDefined: isNativeShadowDefined,
6977
6925
  isSyntheticShadowDefined: isSyntheticShadowDefined,
6978
6926
  HTMLElementExported: HTMLElementExported,
6979
- isHydrating: isHydrating,
6980
6927
  insert: insert,
6981
6928
  remove: remove,
6982
6929
  cloneNode: cloneNode,
@@ -7078,13 +7025,8 @@ var LWC = (function (exports) {
7078
7025
  }
7079
7026
 
7080
7027
  try {
7081
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7082
- // and uses the same algo to create the stylesheets as in SSR.
7083
- setIsHydrating(true);
7084
7028
  var vm = createVMWithProps(element, Ctor, props);
7085
- hydrateRoot(vm); // set it back since now we finished hydration.
7086
-
7087
- setIsHydrating(false);
7029
+ hydrateRoot(vm);
7088
7030
  } catch (e) {
7089
7031
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
7090
7032
  // with the client generated DOM.
@@ -7095,11 +7037,7 @@ var LWC = (function (exports) {
7095
7037
  resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7096
7038
 
7097
7039
  createVMWithProps(element, Ctor, props);
7098
- setIsHydrating(false);
7099
7040
  connectRootElement(element);
7100
- } finally {
7101
- // in case there's an error during recovery
7102
- setIsHydrating(false);
7103
7041
  }
7104
7042
  }
7105
7043
  /*
@@ -7371,7 +7309,7 @@ var LWC = (function (exports) {
7371
7309
  });
7372
7310
  freeze(LightningElement);
7373
7311
  seal(LightningElement.prototype);
7374
- /* version: 2.22.0 */
7312
+ /* version: 2.23.0 */
7375
7313
 
7376
7314
  exports.LightningElement = LightningElement;
7377
7315
  exports.__unstable__ProfilerControl = profilerControl;