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
@@ -305,9 +305,9 @@
305
305
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
306
306
  */
307
307
  // Increment whenever the LWC template compiler changes
308
- const LWC_VERSION = "2.22.0";
308
+ const LWC_VERSION = "2.23.0";
309
309
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
310
- /** version: 2.22.0 */
310
+ /** version: 2.23.0 */
311
311
 
312
312
  /*
313
313
  * Copyright (c) 2018, salesforce.com, inc.
@@ -461,7 +461,7 @@
461
461
  setFeatureFlag(name, value);
462
462
  }
463
463
  }
464
- /** version: 2.22.0 */
464
+ /** version: 2.23.0 */
465
465
 
466
466
  /*
467
467
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1266,6 +1266,14 @@
1266
1266
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1267
1267
  }
1268
1268
 
1269
+ function updateComponentValue(vm, key, newValue) {
1270
+ const { cmpFields } = vm;
1271
+ if (newValue !== cmpFields[key]) {
1272
+ cmpFields[key] = newValue;
1273
+ componentValueMutated(vm, key);
1274
+ }
1275
+ }
1276
+
1269
1277
  /**
1270
1278
  * Copyright (C) 2017 salesforce.com, inc.
1271
1279
  */
@@ -1898,10 +1906,7 @@
1898
1906
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1899
1907
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1900
1908
  }
1901
- if (newValue !== vm.cmpProps[propName]) {
1902
- vm.cmpProps[propName] = newValue;
1903
- componentValueMutated(vm, propName);
1904
- }
1909
+ updateComponentValue(vm, propName, newValue);
1905
1910
  return set.call(vm.elm, newValue);
1906
1911
  },
1907
1912
  };
@@ -2196,10 +2201,7 @@
2196
2201
  },
2197
2202
  set(newValue) {
2198
2203
  const vm = getAssociatedVM(this);
2199
- if (newValue !== vm.cmpFields[key]) {
2200
- vm.cmpFields[key] = newValue;
2201
- componentValueMutated(vm, key);
2202
- }
2204
+ updateComponentValue(vm, key, newValue);
2203
2205
  },
2204
2206
  enumerable: true,
2205
2207
  configurable: true,
@@ -2386,10 +2388,7 @@
2386
2388
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2387
2389
  }
2388
2390
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2389
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2390
- vm.cmpFields[key] = reactiveOrAnyValue;
2391
- componentValueMutated(vm, key);
2392
- }
2391
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2393
2392
  },
2394
2393
  enumerable: true,
2395
2394
  configurable: true,
@@ -2428,10 +2427,7 @@
2428
2427
  * letting the author to do the wrong thing, but it will keep our
2429
2428
  * system to be backward compatible.
2430
2429
  */
2431
- if (value !== vm.cmpFields[key]) {
2432
- vm.cmpFields[key] = value;
2433
- componentValueMutated(vm, key);
2434
- }
2430
+ updateComponentValue(vm, key, value);
2435
2431
  },
2436
2432
  enumerable: true,
2437
2433
  configurable: true,
@@ -3520,13 +3516,13 @@
3520
3516
  return owner;
3521
3517
  }
3522
3518
  function createStylesheet(vm, stylesheets) {
3523
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3519
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3524
3520
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3525
3521
  for (let i = 0; i < stylesheets.length; i++) {
3526
3522
  insertStylesheet(stylesheets[i]);
3527
3523
  }
3528
3524
  }
3529
- else if (ssr || vm.hydrated) {
3525
+ else if (vm.hydrated) {
3530
3526
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3531
3527
  // This works in the client, because the stylesheets are created, and cached in the VM
3532
3528
  // the first time the VM renders.
@@ -3827,7 +3823,7 @@
3827
3823
  updateStaticChildren(c1, c2, parent, renderer);
3828
3824
  }
3829
3825
  }
3830
- function patch(n1, n2, renderer) {
3826
+ function patch(n1, n2, parent, renderer) {
3831
3827
  var _a, _b;
3832
3828
  if (n1 === n2) {
3833
3829
  return;
@@ -3856,7 +3852,7 @@
3856
3852
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3857
3853
  break;
3858
3854
  case 3 /* VNodeType.CustomElement */:
3859
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3855
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3860
3856
  break;
3861
3857
  }
3862
3858
  }
@@ -3983,22 +3979,32 @@
3983
3979
  appendVM(vm);
3984
3980
  }
3985
3981
  }
3986
- function patchCustomElement(n1, n2, renderer) {
3987
- const elm = (n2.elm = n1.elm);
3988
- const vm = (n2.vm = n1.vm);
3989
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3990
- if (!isUndefined$1(vm)) {
3991
- // in fallback mode, the allocation will always set children to
3992
- // empty and delegate the real allocation to the slot elements
3993
- allocateChildren(n2, vm);
3982
+ function patchCustomElement(n1, n2, parent, renderer) {
3983
+ if (n1.ctor !== n2.ctor) {
3984
+ // If the constructor, unmount the current component and mount a new one using the new
3985
+ // constructor.
3986
+ const anchor = renderer.nextSibling(n1.elm);
3987
+ unmount(n1, parent, renderer, true);
3988
+ mountCustomElement(n2, parent, anchor, renderer);
3994
3989
  }
3995
- // in fallback mode, the children will be always empty, so, nothing
3996
- // will happen, but in native, it does allocate the light dom
3997
- patchChildren(n1.children, n2.children, elm, renderer);
3998
- if (!isUndefined$1(vm)) {
3999
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
4000
- // this is important to preserve the top to bottom synchronous rendering phase.
4001
- rerenderVM(vm);
3990
+ else {
3991
+ // Otherwise patch the existing component with new props/attrs/etc.
3992
+ const elm = (n2.elm = n1.elm);
3993
+ const vm = (n2.vm = n1.vm);
3994
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3995
+ if (!isUndefined$1(vm)) {
3996
+ // in fallback mode, the allocation will always set children to
3997
+ // empty and delegate the real allocation to the slot elements
3998
+ allocateChildren(n2, vm);
3999
+ }
4000
+ // in fallback mode, the children will be always empty, so, nothing
4001
+ // will happen, but in native, it does allocate the light dom
4002
+ patchChildren(n1.children, n2.children, elm, renderer);
4003
+ if (!isUndefined$1(vm)) {
4004
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4005
+ // this is important to preserve the top to bottom synchronous rendering phase.
4006
+ rerenderVM(vm);
4007
+ }
4002
4008
  }
4003
4009
  }
4004
4010
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4268,25 +4274,25 @@
4268
4274
  newEndVnode = newCh[--newEndIdx];
4269
4275
  }
4270
4276
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4271
- patch(oldStartVnode, newStartVnode, renderer);
4277
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4272
4278
  oldStartVnode = oldCh[++oldStartIdx];
4273
4279
  newStartVnode = newCh[++newStartIdx];
4274
4280
  }
4275
4281
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4276
- patch(oldEndVnode, newEndVnode, renderer);
4282
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4277
4283
  oldEndVnode = oldCh[--oldEndIdx];
4278
4284
  newEndVnode = newCh[--newEndIdx];
4279
4285
  }
4280
4286
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4281
4287
  // Vnode moved right
4282
- patch(oldStartVnode, newEndVnode, renderer);
4288
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4283
4289
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4284
4290
  oldStartVnode = oldCh[++oldStartIdx];
4285
4291
  newEndVnode = newCh[--newEndIdx];
4286
4292
  }
4287
4293
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4288
4294
  // Vnode moved left
4289
- patch(oldEndVnode, newStartVnode, renderer);
4295
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4290
4296
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4291
4297
  oldEndVnode = oldCh[--oldEndIdx];
4292
4298
  newStartVnode = newCh[++newStartIdx];
@@ -4309,7 +4315,7 @@
4309
4315
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4310
4316
  }
4311
4317
  else {
4312
- patch(elmToMove, newStartVnode, renderer);
4318
+ patch(elmToMove, newStartVnode, parent, renderer);
4313
4319
  // Delete the old child, but copy the array since it is read-only.
4314
4320
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4315
4321
  // so we only care about the `oldCh` object inside this function.
@@ -4369,7 +4375,7 @@
4369
4375
  if (isVNode(n1)) {
4370
4376
  if (isVNode(n2)) {
4371
4377
  // both vnodes are equivalent, and we just need to patch them
4372
- patch(n1, n2, renderer);
4378
+ patch(n1, n2, parent, renderer);
4373
4379
  anchor = n2.elm;
4374
4380
  }
4375
4381
  else {
@@ -4703,13 +4709,6 @@
4703
4709
  }
4704
4710
  return url;
4705
4711
  }
4706
- /**
4707
- * Map to store an index value assigned to any dynamic component reference ingested
4708
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4709
- * component reference to avoid diffing algo mismatches.
4710
- */
4711
- const DynamicImportedComponentMap = new Map();
4712
- let dynamicImportedComponentCounter = 0;
4713
4712
  /**
4714
4713
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4715
4714
  */
@@ -4726,18 +4725,7 @@
4726
4725
  if (!isComponentConstructor(Ctor)) {
4727
4726
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4728
4727
  }
4729
- let idx = DynamicImportedComponentMap.get(Ctor);
4730
- if (isUndefined$1(idx)) {
4731
- idx = dynamicImportedComponentCounter++;
4732
- DynamicImportedComponentMap.set(Ctor, idx);
4733
- }
4734
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4735
- // to identify different constructors as vnodes with different keys to avoid reusing the
4736
- // element used for previous constructors.
4737
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4738
- // hoisting optimization.
4739
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4740
- return c(sel, Ctor, newData, children);
4728
+ return c(sel, Ctor, data, children);
4741
4729
  }
4742
4730
  /**
4743
4731
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5631,16 +5619,9 @@
5631
5619
  const {
5632
5620
  def: {
5633
5621
  renderedCallback
5634
- },
5635
- renderer: {
5636
- ssr
5637
5622
  }
5638
5623
  } = vm;
5639
5624
 
5640
- if (isTrue(ssr)) {
5641
- return;
5642
- }
5643
-
5644
5625
  const {
5645
5626
  rendered
5646
5627
  } = Services;
@@ -5890,13 +5871,7 @@
5890
5871
  vm.velements = EmptyArray;
5891
5872
  }
5892
5873
  function scheduleRehydration(vm) {
5893
- const {
5894
- renderer: {
5895
- ssr
5896
- }
5897
- } = vm;
5898
-
5899
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5874
+ if (isTrue(vm.isScheduled)) {
5900
5875
  return;
5901
5876
  }
5902
5877
 
@@ -6003,15 +5978,8 @@
6003
5978
  }
6004
5979
 
6005
5980
  function createFieldDataCallback(vm, name) {
6006
- const {
6007
- cmpFields
6008
- } = vm;
6009
5981
  return value => {
6010
- if (value !== vm.cmpFields[name]) {
6011
- // storing the value in the underlying storage
6012
- cmpFields[name] = value;
6013
- componentValueMutated(vm, name);
6014
- }
5982
+ updateComponentValue(vm, name, value);
6015
5983
  };
6016
5984
  }
6017
5985
 
@@ -6835,7 +6803,7 @@
6835
6803
  }
6836
6804
  return ctor;
6837
6805
  }
6838
- /* version: 2.22.0 */
6806
+ /* version: 2.23.0 */
6839
6807
 
6840
6808
  /*
6841
6809
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7107,14 +7075,6 @@
7107
7075
  };
7108
7076
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7109
7077
  }
7110
- let hydrating = false;
7111
- function setIsHydrating(value) {
7112
- hydrating = value;
7113
- }
7114
- const ssr = false;
7115
- function isHydrating() {
7116
- return hydrating;
7117
- }
7118
7078
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7119
7079
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7120
7080
  function cloneNode(node, deep) {
@@ -7141,15 +7101,11 @@
7141
7101
  return node.nextSibling;
7142
7102
  }
7143
7103
  function attachShadow(element, options) {
7144
- // `hydrating` will be true in two cases:
7104
+ // `shadowRoot` will be non-null in two cases:
7145
7105
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7146
7106
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7147
- // root component with customeElement.define('c-app', Ctor)
7148
- //
7149
- // The second case can be treated as a failed hydration with nominal impact
7150
- // to performance. However, because <c-app> won't have a <template shadowroot>
7151
- // declarative child, `element.shadowRoot` is `null`.
7152
- if (hydrating && element.shadowRoot) {
7107
+ // root component with customElement.define('c-app', Ctor)
7108
+ if (!isNull(element.shadowRoot)) {
7153
7109
  return element.shadowRoot;
7154
7110
  }
7155
7111
  return element.attachShadow(options);
@@ -7245,11 +7201,9 @@
7245
7201
  }
7246
7202
  const HTMLElementExported = HTMLElementConstructor;
7247
7203
  const renderer = {
7248
- ssr,
7249
7204
  isNativeShadowDefined,
7250
7205
  isSyntheticShadowDefined,
7251
7206
  HTMLElementExported,
7252
- isHydrating,
7253
7207
  insert,
7254
7208
  remove,
7255
7209
  cloneNode,
@@ -7335,13 +7289,8 @@
7335
7289
  return;
7336
7290
  }
7337
7291
  try {
7338
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7339
- // and uses the same algo to create the stylesheets as in SSR.
7340
- setIsHydrating(true);
7341
7292
  const vm = createVMWithProps(element, Ctor, props);
7342
7293
  hydrateRoot(vm);
7343
- // set it back since now we finished hydration.
7344
- setIsHydrating(false);
7345
7294
  }
7346
7295
  catch (e) {
7347
7296
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7352,13 +7301,8 @@
7352
7301
  resetShadowRootAndLightDom(element, Ctor);
7353
7302
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7354
7303
  createVMWithProps(element, Ctor, props);
7355
- setIsHydrating(false);
7356
7304
  connectRootElement(element);
7357
7305
  }
7358
- finally {
7359
- // in case there's an error during recovery
7360
- setIsHydrating(false);
7361
- }
7362
7306
  }
7363
7307
 
7364
7308
  /*
@@ -7583,7 +7527,7 @@
7583
7527
  });
7584
7528
  freeze(LightningElement);
7585
7529
  seal(LightningElement.prototype);
7586
- /* version: 2.22.0 */
7530
+ /* version: 2.23.0 */
7587
7531
 
7588
7532
  exports.LightningElement = LightningElement;
7589
7533
  exports.__unstable__ProfilerControl = profilerControl;