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
@@ -302,9 +302,9 @@ var LWC = (function (exports) {
302
302
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
303
303
  */
304
304
  // Increment whenever the LWC template compiler changes
305
- const LWC_VERSION = "2.22.0";
305
+ const LWC_VERSION = "2.23.0";
306
306
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
307
- /** version: 2.22.0 */
307
+ /** version: 2.23.0 */
308
308
 
309
309
  /*
310
310
  * Copyright (c) 2018, salesforce.com, inc.
@@ -458,7 +458,7 @@ var LWC = (function (exports) {
458
458
  setFeatureFlag(name, value);
459
459
  }
460
460
  }
461
- /** version: 2.22.0 */
461
+ /** version: 2.23.0 */
462
462
 
463
463
  /*
464
464
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1263,6 +1263,14 @@ var LWC = (function (exports) {
1263
1263
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1264
1264
  }
1265
1265
 
1266
+ function updateComponentValue(vm, key, newValue) {
1267
+ const { cmpFields } = vm;
1268
+ if (newValue !== cmpFields[key]) {
1269
+ cmpFields[key] = newValue;
1270
+ componentValueMutated(vm, key);
1271
+ }
1272
+ }
1273
+
1266
1274
  /**
1267
1275
  * Copyright (C) 2017 salesforce.com, inc.
1268
1276
  */
@@ -1895,10 +1903,7 @@ var LWC = (function (exports) {
1895
1903
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1896
1904
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1897
1905
  }
1898
- if (newValue !== vm.cmpProps[propName]) {
1899
- vm.cmpProps[propName] = newValue;
1900
- componentValueMutated(vm, propName);
1901
- }
1906
+ updateComponentValue(vm, propName, newValue);
1902
1907
  return set.call(vm.elm, newValue);
1903
1908
  },
1904
1909
  };
@@ -2193,10 +2198,7 @@ var LWC = (function (exports) {
2193
2198
  },
2194
2199
  set(newValue) {
2195
2200
  const vm = getAssociatedVM(this);
2196
- if (newValue !== vm.cmpFields[key]) {
2197
- vm.cmpFields[key] = newValue;
2198
- componentValueMutated(vm, key);
2199
- }
2201
+ updateComponentValue(vm, key, newValue);
2200
2202
  },
2201
2203
  enumerable: true,
2202
2204
  configurable: true,
@@ -2383,10 +2385,7 @@ var LWC = (function (exports) {
2383
2385
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2384
2386
  }
2385
2387
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2386
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2387
- vm.cmpFields[key] = reactiveOrAnyValue;
2388
- componentValueMutated(vm, key);
2389
- }
2388
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2390
2389
  },
2391
2390
  enumerable: true,
2392
2391
  configurable: true,
@@ -2425,10 +2424,7 @@ var LWC = (function (exports) {
2425
2424
  * letting the author to do the wrong thing, but it will keep our
2426
2425
  * system to be backward compatible.
2427
2426
  */
2428
- if (value !== vm.cmpFields[key]) {
2429
- vm.cmpFields[key] = value;
2430
- componentValueMutated(vm, key);
2431
- }
2427
+ updateComponentValue(vm, key, value);
2432
2428
  },
2433
2429
  enumerable: true,
2434
2430
  configurable: true,
@@ -3517,13 +3513,13 @@ var LWC = (function (exports) {
3517
3513
  return owner;
3518
3514
  }
3519
3515
  function createStylesheet(vm, stylesheets) {
3520
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3516
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3521
3517
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3522
3518
  for (let i = 0; i < stylesheets.length; i++) {
3523
3519
  insertStylesheet(stylesheets[i]);
3524
3520
  }
3525
3521
  }
3526
- else if (ssr || vm.hydrated) {
3522
+ else if (vm.hydrated) {
3527
3523
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3528
3524
  // This works in the client, because the stylesheets are created, and cached in the VM
3529
3525
  // the first time the VM renders.
@@ -3824,7 +3820,7 @@ var LWC = (function (exports) {
3824
3820
  updateStaticChildren(c1, c2, parent, renderer);
3825
3821
  }
3826
3822
  }
3827
- function patch(n1, n2, renderer) {
3823
+ function patch(n1, n2, parent, renderer) {
3828
3824
  var _a, _b;
3829
3825
  if (n1 === n2) {
3830
3826
  return;
@@ -3853,7 +3849,7 @@ var LWC = (function (exports) {
3853
3849
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3854
3850
  break;
3855
3851
  case 3 /* VNodeType.CustomElement */:
3856
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3852
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3857
3853
  break;
3858
3854
  }
3859
3855
  }
@@ -3980,22 +3976,32 @@ var LWC = (function (exports) {
3980
3976
  appendVM(vm);
3981
3977
  }
3982
3978
  }
3983
- function patchCustomElement(n1, n2, renderer) {
3984
- const elm = (n2.elm = n1.elm);
3985
- const vm = (n2.vm = n1.vm);
3986
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3987
- if (!isUndefined$1(vm)) {
3988
- // in fallback mode, the allocation will always set children to
3989
- // empty and delegate the real allocation to the slot elements
3990
- allocateChildren(n2, vm);
3979
+ function patchCustomElement(n1, n2, parent, renderer) {
3980
+ if (n1.ctor !== n2.ctor) {
3981
+ // If the constructor, unmount the current component and mount a new one using the new
3982
+ // constructor.
3983
+ const anchor = renderer.nextSibling(n1.elm);
3984
+ unmount(n1, parent, renderer, true);
3985
+ mountCustomElement(n2, parent, anchor, renderer);
3991
3986
  }
3992
- // in fallback mode, the children will be always empty, so, nothing
3993
- // will happen, but in native, it does allocate the light dom
3994
- patchChildren(n1.children, n2.children, elm, renderer);
3995
- if (!isUndefined$1(vm)) {
3996
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3997
- // this is important to preserve the top to bottom synchronous rendering phase.
3998
- rerenderVM(vm);
3987
+ else {
3988
+ // Otherwise patch the existing component with new props/attrs/etc.
3989
+ const elm = (n2.elm = n1.elm);
3990
+ const vm = (n2.vm = n1.vm);
3991
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3992
+ if (!isUndefined$1(vm)) {
3993
+ // in fallback mode, the allocation will always set children to
3994
+ // empty and delegate the real allocation to the slot elements
3995
+ allocateChildren(n2, vm);
3996
+ }
3997
+ // in fallback mode, the children will be always empty, so, nothing
3998
+ // will happen, but in native, it does allocate the light dom
3999
+ patchChildren(n1.children, n2.children, elm, renderer);
4000
+ if (!isUndefined$1(vm)) {
4001
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4002
+ // this is important to preserve the top to bottom synchronous rendering phase.
4003
+ rerenderVM(vm);
4004
+ }
3999
4005
  }
4000
4006
  }
4001
4007
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4265,25 +4271,25 @@ var LWC = (function (exports) {
4265
4271
  newEndVnode = newCh[--newEndIdx];
4266
4272
  }
4267
4273
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4268
- patch(oldStartVnode, newStartVnode, renderer);
4274
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4269
4275
  oldStartVnode = oldCh[++oldStartIdx];
4270
4276
  newStartVnode = newCh[++newStartIdx];
4271
4277
  }
4272
4278
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4273
- patch(oldEndVnode, newEndVnode, renderer);
4279
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4274
4280
  oldEndVnode = oldCh[--oldEndIdx];
4275
4281
  newEndVnode = newCh[--newEndIdx];
4276
4282
  }
4277
4283
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4278
4284
  // Vnode moved right
4279
- patch(oldStartVnode, newEndVnode, renderer);
4285
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4280
4286
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4281
4287
  oldStartVnode = oldCh[++oldStartIdx];
4282
4288
  newEndVnode = newCh[--newEndIdx];
4283
4289
  }
4284
4290
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4285
4291
  // Vnode moved left
4286
- patch(oldEndVnode, newStartVnode, renderer);
4292
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4287
4293
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4288
4294
  oldEndVnode = oldCh[--oldEndIdx];
4289
4295
  newStartVnode = newCh[++newStartIdx];
@@ -4306,7 +4312,7 @@ var LWC = (function (exports) {
4306
4312
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4307
4313
  }
4308
4314
  else {
4309
- patch(elmToMove, newStartVnode, renderer);
4315
+ patch(elmToMove, newStartVnode, parent, renderer);
4310
4316
  // Delete the old child, but copy the array since it is read-only.
4311
4317
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4312
4318
  // so we only care about the `oldCh` object inside this function.
@@ -4366,7 +4372,7 @@ var LWC = (function (exports) {
4366
4372
  if (isVNode(n1)) {
4367
4373
  if (isVNode(n2)) {
4368
4374
  // both vnodes are equivalent, and we just need to patch them
4369
- patch(n1, n2, renderer);
4375
+ patch(n1, n2, parent, renderer);
4370
4376
  anchor = n2.elm;
4371
4377
  }
4372
4378
  else {
@@ -4700,13 +4706,6 @@ var LWC = (function (exports) {
4700
4706
  }
4701
4707
  return url;
4702
4708
  }
4703
- /**
4704
- * Map to store an index value assigned to any dynamic component reference ingested
4705
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4706
- * component reference to avoid diffing algo mismatches.
4707
- */
4708
- const DynamicImportedComponentMap = new Map();
4709
- let dynamicImportedComponentCounter = 0;
4710
4709
  /**
4711
4710
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4712
4711
  */
@@ -4723,18 +4722,7 @@ var LWC = (function (exports) {
4723
4722
  if (!isComponentConstructor(Ctor)) {
4724
4723
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4725
4724
  }
4726
- let idx = DynamicImportedComponentMap.get(Ctor);
4727
- if (isUndefined$1(idx)) {
4728
- idx = dynamicImportedComponentCounter++;
4729
- DynamicImportedComponentMap.set(Ctor, idx);
4730
- }
4731
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4732
- // to identify different constructors as vnodes with different keys to avoid reusing the
4733
- // element used for previous constructors.
4734
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4735
- // hoisting optimization.
4736
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4737
- return c(sel, Ctor, newData, children);
4725
+ return c(sel, Ctor, data, children);
4738
4726
  }
4739
4727
  /**
4740
4728
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5628,16 +5616,9 @@ var LWC = (function (exports) {
5628
5616
  const {
5629
5617
  def: {
5630
5618
  renderedCallback
5631
- },
5632
- renderer: {
5633
- ssr
5634
5619
  }
5635
5620
  } = vm;
5636
5621
 
5637
- if (isTrue(ssr)) {
5638
- return;
5639
- }
5640
-
5641
5622
  const {
5642
5623
  rendered
5643
5624
  } = Services;
@@ -5887,13 +5868,7 @@ var LWC = (function (exports) {
5887
5868
  vm.velements = EmptyArray;
5888
5869
  }
5889
5870
  function scheduleRehydration(vm) {
5890
- const {
5891
- renderer: {
5892
- ssr
5893
- }
5894
- } = vm;
5895
-
5896
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5871
+ if (isTrue(vm.isScheduled)) {
5897
5872
  return;
5898
5873
  }
5899
5874
 
@@ -6000,15 +5975,8 @@ var LWC = (function (exports) {
6000
5975
  }
6001
5976
 
6002
5977
  function createFieldDataCallback(vm, name) {
6003
- const {
6004
- cmpFields
6005
- } = vm;
6006
5978
  return value => {
6007
- if (value !== vm.cmpFields[name]) {
6008
- // storing the value in the underlying storage
6009
- cmpFields[name] = value;
6010
- componentValueMutated(vm, name);
6011
- }
5979
+ updateComponentValue(vm, name, value);
6012
5980
  };
6013
5981
  }
6014
5982
 
@@ -6832,7 +6800,7 @@ var LWC = (function (exports) {
6832
6800
  }
6833
6801
  return ctor;
6834
6802
  }
6835
- /* version: 2.22.0 */
6803
+ /* version: 2.23.0 */
6836
6804
 
6837
6805
  /*
6838
6806
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7104,14 +7072,6 @@ var LWC = (function (exports) {
7104
7072
  };
7105
7073
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7106
7074
  }
7107
- let hydrating = false;
7108
- function setIsHydrating(value) {
7109
- hydrating = value;
7110
- }
7111
- const ssr = false;
7112
- function isHydrating() {
7113
- return hydrating;
7114
- }
7115
7075
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7116
7076
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7117
7077
  function cloneNode(node, deep) {
@@ -7138,15 +7098,11 @@ var LWC = (function (exports) {
7138
7098
  return node.nextSibling;
7139
7099
  }
7140
7100
  function attachShadow(element, options) {
7141
- // `hydrating` will be true in two cases:
7101
+ // `shadowRoot` will be non-null in two cases:
7142
7102
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7143
7103
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7144
- // root component with customeElement.define('c-app', Ctor)
7145
- //
7146
- // The second case can be treated as a failed hydration with nominal impact
7147
- // to performance. However, because <c-app> won't have a <template shadowroot>
7148
- // declarative child, `element.shadowRoot` is `null`.
7149
- if (hydrating && element.shadowRoot) {
7104
+ // root component with customElement.define('c-app', Ctor)
7105
+ if (!isNull(element.shadowRoot)) {
7150
7106
  return element.shadowRoot;
7151
7107
  }
7152
7108
  return element.attachShadow(options);
@@ -7242,11 +7198,9 @@ var LWC = (function (exports) {
7242
7198
  }
7243
7199
  const HTMLElementExported = HTMLElementConstructor;
7244
7200
  const renderer = {
7245
- ssr,
7246
7201
  isNativeShadowDefined,
7247
7202
  isSyntheticShadowDefined,
7248
7203
  HTMLElementExported,
7249
- isHydrating,
7250
7204
  insert,
7251
7205
  remove,
7252
7206
  cloneNode,
@@ -7332,13 +7286,8 @@ var LWC = (function (exports) {
7332
7286
  return;
7333
7287
  }
7334
7288
  try {
7335
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7336
- // and uses the same algo to create the stylesheets as in SSR.
7337
- setIsHydrating(true);
7338
7289
  const vm = createVMWithProps(element, Ctor, props);
7339
7290
  hydrateRoot(vm);
7340
- // set it back since now we finished hydration.
7341
- setIsHydrating(false);
7342
7291
  }
7343
7292
  catch (e) {
7344
7293
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7349,13 +7298,8 @@ var LWC = (function (exports) {
7349
7298
  resetShadowRootAndLightDom(element, Ctor);
7350
7299
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7351
7300
  createVMWithProps(element, Ctor, props);
7352
- setIsHydrating(false);
7353
7301
  connectRootElement(element);
7354
7302
  }
7355
- finally {
7356
- // in case there's an error during recovery
7357
- setIsHydrating(false);
7358
- }
7359
7303
  }
7360
7304
 
7361
7305
  /*
@@ -7580,7 +7524,7 @@ var LWC = (function (exports) {
7580
7524
  });
7581
7525
  freeze(LightningElement);
7582
7526
  seal(LightningElement.prototype);
7583
- /* version: 2.22.0 */
7527
+ /* version: 2.23.0 */
7584
7528
 
7585
7529
  exports.LightningElement = LightningElement;
7586
7530
  exports.__unstable__ProfilerControl = profilerControl;