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
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.22.0";
302
+ const LWC_VERSION = "2.23.0";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.22.0 */
304
+ /** version: 2.23.0 */
305
305
 
306
306
  /*
307
307
  * Copyright (c) 2018, salesforce.com, inc.
@@ -455,7 +455,7 @@ function setFeatureFlagForTest(name, value) {
455
455
  setFeatureFlag(name, value);
456
456
  }
457
457
  }
458
- /** version: 2.22.0 */
458
+ /** version: 2.23.0 */
459
459
 
460
460
  /*
461
461
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1260,6 +1260,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
1260
1260
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1261
1261
  }
1262
1262
 
1263
+ function updateComponentValue(vm, key, newValue) {
1264
+ const { cmpFields } = vm;
1265
+ if (newValue !== cmpFields[key]) {
1266
+ cmpFields[key] = newValue;
1267
+ componentValueMutated(vm, key);
1268
+ }
1269
+ }
1270
+
1263
1271
  /**
1264
1272
  * Copyright (C) 2017 salesforce.com, inc.
1265
1273
  */
@@ -1892,10 +1900,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1892
1900
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1893
1901
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1894
1902
  }
1895
- if (newValue !== vm.cmpProps[propName]) {
1896
- vm.cmpProps[propName] = newValue;
1897
- componentValueMutated(vm, propName);
1898
- }
1903
+ updateComponentValue(vm, propName, newValue);
1899
1904
  return set.call(vm.elm, newValue);
1900
1905
  },
1901
1906
  };
@@ -2190,10 +2195,7 @@ function createObservedFieldPropertyDescriptor(key) {
2190
2195
  },
2191
2196
  set(newValue) {
2192
2197
  const vm = getAssociatedVM(this);
2193
- if (newValue !== vm.cmpFields[key]) {
2194
- vm.cmpFields[key] = newValue;
2195
- componentValueMutated(vm, key);
2196
- }
2198
+ updateComponentValue(vm, key, newValue);
2197
2199
  },
2198
2200
  enumerable: true,
2199
2201
  configurable: true,
@@ -2380,10 +2382,7 @@ function internalTrackDecorator(key) {
2380
2382
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2381
2383
  }
2382
2384
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2383
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2384
- vm.cmpFields[key] = reactiveOrAnyValue;
2385
- componentValueMutated(vm, key);
2386
- }
2385
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2387
2386
  },
2388
2387
  enumerable: true,
2389
2388
  configurable: true,
@@ -2422,10 +2421,7 @@ function internalWireFieldDecorator(key) {
2422
2421
  * letting the author to do the wrong thing, but it will keep our
2423
2422
  * system to be backward compatible.
2424
2423
  */
2425
- if (value !== vm.cmpFields[key]) {
2426
- vm.cmpFields[key] = value;
2427
- componentValueMutated(vm, key);
2428
- }
2424
+ updateComponentValue(vm, key, value);
2429
2425
  },
2430
2426
  enumerable: true,
2431
2427
  configurable: true,
@@ -3514,13 +3510,13 @@ function getNearestNativeShadowComponent(vm) {
3514
3510
  return owner;
3515
3511
  }
3516
3512
  function createStylesheet(vm, stylesheets) {
3517
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3513
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3518
3514
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3519
3515
  for (let i = 0; i < stylesheets.length; i++) {
3520
3516
  insertStylesheet(stylesheets[i]);
3521
3517
  }
3522
3518
  }
3523
- else if (ssr || vm.hydrated) {
3519
+ else if (vm.hydrated) {
3524
3520
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3525
3521
  // This works in the client, because the stylesheets are created, and cached in the VM
3526
3522
  // the first time the VM renders.
@@ -3821,7 +3817,7 @@ function patchChildren(c1, c2, parent, renderer) {
3821
3817
  updateStaticChildren(c1, c2, parent, renderer);
3822
3818
  }
3823
3819
  }
3824
- function patch(n1, n2, renderer) {
3820
+ function patch(n1, n2, parent, renderer) {
3825
3821
  var _a, _b;
3826
3822
  if (n1 === n2) {
3827
3823
  return;
@@ -3850,7 +3846,7 @@ function patch(n1, n2, renderer) {
3850
3846
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3851
3847
  break;
3852
3848
  case 3 /* VNodeType.CustomElement */:
3853
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3849
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3854
3850
  break;
3855
3851
  }
3856
3852
  }
@@ -3977,22 +3973,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3977
3973
  appendVM(vm);
3978
3974
  }
3979
3975
  }
3980
- function patchCustomElement(n1, n2, renderer) {
3981
- const elm = (n2.elm = n1.elm);
3982
- const vm = (n2.vm = n1.vm);
3983
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3984
- if (!isUndefined$1(vm)) {
3985
- // in fallback mode, the allocation will always set children to
3986
- // empty and delegate the real allocation to the slot elements
3987
- allocateChildren(n2, vm);
3976
+ function patchCustomElement(n1, n2, parent, renderer) {
3977
+ if (n1.ctor !== n2.ctor) {
3978
+ // If the constructor, unmount the current component and mount a new one using the new
3979
+ // constructor.
3980
+ const anchor = renderer.nextSibling(n1.elm);
3981
+ unmount(n1, parent, renderer, true);
3982
+ mountCustomElement(n2, parent, anchor, renderer);
3988
3983
  }
3989
- // in fallback mode, the children will be always empty, so, nothing
3990
- // will happen, but in native, it does allocate the light dom
3991
- patchChildren(n1.children, n2.children, elm, renderer);
3992
- if (!isUndefined$1(vm)) {
3993
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3994
- // this is important to preserve the top to bottom synchronous rendering phase.
3995
- rerenderVM(vm);
3984
+ else {
3985
+ // Otherwise patch the existing component with new props/attrs/etc.
3986
+ const elm = (n2.elm = n1.elm);
3987
+ const vm = (n2.vm = n1.vm);
3988
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3989
+ if (!isUndefined$1(vm)) {
3990
+ // in fallback mode, the allocation will always set children to
3991
+ // empty and delegate the real allocation to the slot elements
3992
+ allocateChildren(n2, vm);
3993
+ }
3994
+ // in fallback mode, the children will be always empty, so, nothing
3995
+ // will happen, but in native, it does allocate the light dom
3996
+ patchChildren(n1.children, n2.children, elm, renderer);
3997
+ if (!isUndefined$1(vm)) {
3998
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3999
+ // this is important to preserve the top to bottom synchronous rendering phase.
4000
+ rerenderVM(vm);
4001
+ }
3996
4002
  }
3997
4003
  }
3998
4004
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4262,25 +4268,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4262
4268
  newEndVnode = newCh[--newEndIdx];
4263
4269
  }
4264
4270
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4265
- patch(oldStartVnode, newStartVnode, renderer);
4271
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4266
4272
  oldStartVnode = oldCh[++oldStartIdx];
4267
4273
  newStartVnode = newCh[++newStartIdx];
4268
4274
  }
4269
4275
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4270
- patch(oldEndVnode, newEndVnode, renderer);
4276
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4271
4277
  oldEndVnode = oldCh[--oldEndIdx];
4272
4278
  newEndVnode = newCh[--newEndIdx];
4273
4279
  }
4274
4280
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4275
4281
  // Vnode moved right
4276
- patch(oldStartVnode, newEndVnode, renderer);
4282
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4277
4283
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4278
4284
  oldStartVnode = oldCh[++oldStartIdx];
4279
4285
  newEndVnode = newCh[--newEndIdx];
4280
4286
  }
4281
4287
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4282
4288
  // Vnode moved left
4283
- patch(oldEndVnode, newStartVnode, renderer);
4289
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4284
4290
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4285
4291
  oldEndVnode = oldCh[--oldEndIdx];
4286
4292
  newStartVnode = newCh[++newStartIdx];
@@ -4303,7 +4309,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4303
4309
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4304
4310
  }
4305
4311
  else {
4306
- patch(elmToMove, newStartVnode, renderer);
4312
+ patch(elmToMove, newStartVnode, parent, renderer);
4307
4313
  // Delete the old child, but copy the array since it is read-only.
4308
4314
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4309
4315
  // so we only care about the `oldCh` object inside this function.
@@ -4363,7 +4369,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
4363
4369
  if (isVNode(n1)) {
4364
4370
  if (isVNode(n2)) {
4365
4371
  // both vnodes are equivalent, and we just need to patch them
4366
- patch(n1, n2, renderer);
4372
+ patch(n1, n2, parent, renderer);
4367
4373
  anchor = n2.elm;
4368
4374
  }
4369
4375
  else {
@@ -4697,13 +4703,6 @@ function fid(url) {
4697
4703
  }
4698
4704
  return url;
4699
4705
  }
4700
- /**
4701
- * Map to store an index value assigned to any dynamic component reference ingested
4702
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4703
- * component reference to avoid diffing algo mismatches.
4704
- */
4705
- const DynamicImportedComponentMap = new Map();
4706
- let dynamicImportedComponentCounter = 0;
4707
4706
  /**
4708
4707
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4709
4708
  */
@@ -4720,18 +4719,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4720
4719
  if (!isComponentConstructor(Ctor)) {
4721
4720
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4722
4721
  }
4723
- let idx = DynamicImportedComponentMap.get(Ctor);
4724
- if (isUndefined$1(idx)) {
4725
- idx = dynamicImportedComponentCounter++;
4726
- DynamicImportedComponentMap.set(Ctor, idx);
4727
- }
4728
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4729
- // to identify different constructors as vnodes with different keys to avoid reusing the
4730
- // element used for previous constructors.
4731
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4732
- // hoisting optimization.
4733
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4734
- return c(sel, Ctor, newData, children);
4722
+ return c(sel, Ctor, data, children);
4735
4723
  }
4736
4724
  /**
4737
4725
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5625,16 +5613,9 @@ function runRenderedCallback(vm) {
5625
5613
  const {
5626
5614
  def: {
5627
5615
  renderedCallback
5628
- },
5629
- renderer: {
5630
- ssr
5631
5616
  }
5632
5617
  } = vm;
5633
5618
 
5634
- if (isTrue(ssr)) {
5635
- return;
5636
- }
5637
-
5638
5619
  const {
5639
5620
  rendered
5640
5621
  } = Services;
@@ -5884,13 +5865,7 @@ function resetComponentRoot(vm) {
5884
5865
  vm.velements = EmptyArray;
5885
5866
  }
5886
5867
  function scheduleRehydration(vm) {
5887
- const {
5888
- renderer: {
5889
- ssr
5890
- }
5891
- } = vm;
5892
-
5893
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5868
+ if (isTrue(vm.isScheduled)) {
5894
5869
  return;
5895
5870
  }
5896
5871
 
@@ -5997,15 +5972,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5997
5972
  }
5998
5973
 
5999
5974
  function createFieldDataCallback(vm, name) {
6000
- const {
6001
- cmpFields
6002
- } = vm;
6003
5975
  return value => {
6004
- if (value !== vm.cmpFields[name]) {
6005
- // storing the value in the underlying storage
6006
- cmpFields[name] = value;
6007
- componentValueMutated(vm, name);
6008
- }
5976
+ updateComponentValue(vm, name, value);
6009
5977
  };
6010
5978
  }
6011
5979
 
@@ -6829,7 +6797,7 @@ function getComponentConstructor(elm) {
6829
6797
  }
6830
6798
  return ctor;
6831
6799
  }
6832
- /* version: 2.22.0 */
6800
+ /* version: 2.23.0 */
6833
6801
 
6834
6802
  /*
6835
6803
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7101,14 +7069,6 @@ else {
7101
7069
  };
7102
7070
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7103
7071
  }
7104
- let hydrating = false;
7105
- function setIsHydrating(value) {
7106
- hydrating = value;
7107
- }
7108
- const ssr = false;
7109
- function isHydrating() {
7110
- return hydrating;
7111
- }
7112
7072
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7113
7073
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7114
7074
  function cloneNode(node, deep) {
@@ -7135,15 +7095,11 @@ function nextSibling(node) {
7135
7095
  return node.nextSibling;
7136
7096
  }
7137
7097
  function attachShadow(element, options) {
7138
- // `hydrating` will be true in two cases:
7098
+ // `shadowRoot` will be non-null in two cases:
7139
7099
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7140
7100
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7141
- // root component with customeElement.define('c-app', Ctor)
7142
- //
7143
- // The second case can be treated as a failed hydration with nominal impact
7144
- // to performance. However, because <c-app> won't have a <template shadowroot>
7145
- // declarative child, `element.shadowRoot` is `null`.
7146
- if (hydrating && element.shadowRoot) {
7101
+ // root component with customElement.define('c-app', Ctor)
7102
+ if (!isNull(element.shadowRoot)) {
7147
7103
  return element.shadowRoot;
7148
7104
  }
7149
7105
  return element.attachShadow(options);
@@ -7239,11 +7195,9 @@ function assertInstanceOfHTMLElement(elm, msg) {
7239
7195
  }
7240
7196
  const HTMLElementExported = HTMLElementConstructor;
7241
7197
  const renderer = {
7242
- ssr,
7243
7198
  isNativeShadowDefined,
7244
7199
  isSyntheticShadowDefined,
7245
7200
  HTMLElementExported,
7246
- isHydrating,
7247
7201
  insert,
7248
7202
  remove,
7249
7203
  cloneNode,
@@ -7329,13 +7283,8 @@ function hydrateComponent(element, Ctor, props = {}) {
7329
7283
  return;
7330
7284
  }
7331
7285
  try {
7332
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7333
- // and uses the same algo to create the stylesheets as in SSR.
7334
- setIsHydrating(true);
7335
7286
  const vm = createVMWithProps(element, Ctor, props);
7336
7287
  hydrateRoot(vm);
7337
- // set it back since now we finished hydration.
7338
- setIsHydrating(false);
7339
7288
  }
7340
7289
  catch (e) {
7341
7290
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7346,13 +7295,8 @@ function hydrateComponent(element, Ctor, props = {}) {
7346
7295
  resetShadowRootAndLightDom(element, Ctor);
7347
7296
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7348
7297
  createVMWithProps(element, Ctor, props);
7349
- setIsHydrating(false);
7350
7298
  connectRootElement(element);
7351
7299
  }
7352
- finally {
7353
- // in case there's an error during recovery
7354
- setIsHydrating(false);
7355
- }
7356
7300
  }
7357
7301
 
7358
7302
  /*
@@ -7577,6 +7521,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7577
7521
  });
7578
7522
  freeze(LightningElement);
7579
7523
  seal(LightningElement.prototype);
7580
- /* version: 2.22.0 */
7524
+ /* version: 2.23.0 */
7581
7525
 
7582
7526
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };