lwc 2.26.2 → 2.28.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 (37) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +137 -31
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +137 -31
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +119 -27
  5. package/dist/engine-dom/iife/es5/engine-dom.js +179 -44
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +158 -40
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +137 -31
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +119 -27
  11. package/dist/engine-dom/umd/es5/engine-dom.js +179 -44
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +158 -40
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +99 -25
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +99 -25
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +4 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4 -4
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
  26. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  28. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  29. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  31. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  37. package/package.json +8 -8
@@ -43,7 +43,7 @@ var assert = /*#__PURE__*/Object.freeze({
43
43
  */
44
44
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
45
45
  const { isArray: isArray$1 } = Array;
46
- const { copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
46
+ const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
47
47
  const { fromCharCode: StringFromCharCode } = String;
48
48
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
49
49
  function isUndefined$1(obj) {
@@ -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.26.2";
302
+ const LWC_VERSION = "2.28.0";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.26.2 */
304
+ /** version: 2.28.0 */
305
305
 
306
306
  /**
307
307
  * Copyright (C) 2018 salesforce.com, inc.
@@ -383,7 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
383
383
  patch$1(propName);
384
384
  }
385
385
  }
386
- /** version: 2.26.2 */
386
+ /** version: 2.28.0 */
387
387
 
388
388
  /**
389
389
  * Copyright (C) 2018 salesforce.com, inc.
@@ -463,7 +463,7 @@ function setFeatureFlagForTest(name, value) {
463
463
  setFeatureFlag(name, value);
464
464
  }
465
465
  }
466
- /** version: 2.26.2 */
466
+ /** version: 2.28.0 */
467
467
 
468
468
  /*
469
469
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3686,6 +3686,9 @@ function isSameVnode(vnode1, vnode2) {
3686
3686
  function isVCustomElement(vnode) {
3687
3687
  return vnode.type === 3 /* VNodeType.CustomElement */;
3688
3688
  }
3689
+ function isVScopedSlotFragment(vnode) {
3690
+ return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3691
+ }
3689
3692
 
3690
3693
  /*
3691
3694
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4519,13 +4522,24 @@ function allocateChildren(vnode, vm) {
4519
4522
  shadowMode
4520
4523
  } = vm;
4521
4524
 
4525
+ if (process.env.NODE_ENV !== 'production') {
4526
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4527
+ // component is a light DOM component. This is mainly to validate light dom parent running
4528
+ // in native shadow mode.
4529
+ if (renderMode !== 0
4530
+ /* RenderMode.Light */
4531
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4532
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4533
+ }
4534
+ }
4535
+
4522
4536
  if (shadowMode === 1
4523
4537
  /* ShadowMode.Synthetic */
4524
4538
  || renderMode === 0
4525
4539
  /* RenderMode.Light */
4526
4540
  ) {
4527
4541
  // slow path
4528
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4542
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4529
4543
 
4530
4544
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4531
4545
 
@@ -4561,13 +4575,19 @@ function createViewModelHook(elm, vnode, renderer) {
4561
4575
  return vm;
4562
4576
  }
4563
4577
 
4564
- function allocateInSlot(vm, children) {
4565
- var _a;
4578
+ function allocateInSlot(vm, children, owner) {
4579
+ var _a, _b;
4566
4580
 
4567
4581
  const {
4568
- cmpSlots: oldSlots
4582
+ cmpSlots: {
4583
+ slotAssignments: oldSlotsMapping
4584
+ }
4569
4585
  } = vm;
4570
- const cmpSlots = vm.cmpSlots = create(null);
4586
+ const cmpSlotsMapping = create(null);
4587
+ vm.cmpSlots = {
4588
+ owner,
4589
+ slotAssignments: cmpSlotsMapping
4590
+ };
4571
4591
 
4572
4592
  for (let i = 0, len = children.length; i < len; i += 1) {
4573
4593
  const vnode = children[i];
@@ -4579,19 +4599,21 @@ function allocateInSlot(vm, children) {
4579
4599
  let slotName = '';
4580
4600
 
4581
4601
  if (isVBaseElement(vnode)) {
4582
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4602
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4603
+ } else if (isVScopedSlotFragment(vnode)) {
4604
+ slotName = vnode.slotName;
4583
4605
  }
4584
4606
 
4585
- const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4607
+ const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4586
4608
  ArrayPush$1.call(vnodes, vnode);
4587
4609
  }
4588
4610
 
4589
4611
  if (isFalse(vm.isDirty)) {
4590
4612
  // We need to determine if the old allocation is really different from the new one
4591
4613
  // and mark the vm as dirty
4592
- const oldKeys = keys(oldSlots);
4614
+ const oldKeys = keys(oldSlotsMapping);
4593
4615
 
4594
- if (oldKeys.length !== keys(cmpSlots).length) {
4616
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4595
4617
  markComponentAsDirty(vm);
4596
4618
  return;
4597
4619
  }
@@ -4599,15 +4621,15 @@ function allocateInSlot(vm, children) {
4599
4621
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4600
4622
  const key = oldKeys[i];
4601
4623
 
4602
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4624
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4603
4625
  markComponentAsDirty(vm);
4604
4626
  return;
4605
4627
  }
4606
4628
 
4607
- const oldVNodes = oldSlots[key];
4608
- const vnodes = cmpSlots[key];
4629
+ const oldVNodes = oldSlotsMapping[key];
4630
+ const vnodes = cmpSlotsMapping[key];
4609
4631
 
4610
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4632
+ for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4611
4633
  if (oldVNodes[j] !== vnodes[j]) {
4612
4634
  markComponentAsDirty(vm);
4613
4635
  return;
@@ -4807,6 +4829,18 @@ const SymbolIterator = Symbol.iterator;
4807
4829
  function addVNodeToChildLWC(vnode) {
4808
4830
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4809
4831
  }
4832
+ // [s]coped [s]lot [f]actory
4833
+ function ssf(slotName, factory) {
4834
+ return {
4835
+ type: 6 /* VNodeType.ScopedSlotFragment */,
4836
+ factory,
4837
+ owner: getVMBeingRendered(),
4838
+ elm: undefined,
4839
+ sel: undefined,
4840
+ key: undefined,
4841
+ slotName,
4842
+ };
4843
+ }
4810
4844
  // [st]atic node
4811
4845
  function st(fragment, key) {
4812
4846
  return {
@@ -4890,9 +4924,46 @@ function s(slotName, data, children, slotset) {
4890
4924
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
4891
4925
  }
4892
4926
  if (!isUndefined$1(slotset) &&
4893
- !isUndefined$1(slotset[slotName]) &&
4894
- slotset[slotName].length !== 0) {
4895
- children = slotset[slotName];
4927
+ !isUndefined$1(slotset.slotAssignments) &&
4928
+ !isUndefined$1(slotset.slotAssignments[slotName]) &&
4929
+ slotset.slotAssignments[slotName].length !== 0) {
4930
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4931
+ if (vnode) {
4932
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4933
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4934
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4935
+ // Check if slot types of parent and child are matching
4936
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4937
+ if (process.env.NODE_ENV !== 'production') {
4938
+ logError(`Mismatched slot types for ${slotName === '' ? '(default)' : slotName} slot. Both parent and child component must use standard type or scoped type for a given slot.`, slotset.owner);
4939
+ }
4940
+ // Ignore slot content from parent
4941
+ return accumulator;
4942
+ }
4943
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4944
+ if (assignedNodeIsScopedSlot) {
4945
+ const vmBeingRenderedInception = getVMBeingRendered();
4946
+ let scopedSlotChildren = [];
4947
+ // Evaluate in the scope of the slot content's owner
4948
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4949
+ // undefined is for root components, but root components cannot accept slotted content
4950
+ setVMBeingRendered(slotset.owner);
4951
+ try {
4952
+ scopedSlotChildren = vnode.factory(data.slotData);
4953
+ }
4954
+ finally {
4955
+ setVMBeingRendered(vmBeingRenderedInception);
4956
+ }
4957
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4958
+ }
4959
+ else {
4960
+ // If the slot content is standard type, the content is static, no additional
4961
+ // processing needed on the vnode
4962
+ return ArrayConcat$1.call(accumulator, vnode);
4963
+ }
4964
+ }
4965
+ return accumulator;
4966
+ }, []);
4896
4967
  }
4897
4968
  const vmBeingRendered = getVMBeingRendered();
4898
4969
  const { renderMode, shadowMode } = vmBeingRendered;
@@ -5212,6 +5283,7 @@ const api = freeze({
5212
5283
  gid,
5213
5284
  fid,
5214
5285
  shc,
5286
+ ssf,
5215
5287
  });
5216
5288
 
5217
5289
  /*
@@ -5348,9 +5420,9 @@ function validateSlots(vm, html) {
5348
5420
  }
5349
5421
  const { cmpSlots } = vm;
5350
5422
  const { slots = EmptyArray } = html;
5351
- for (const slotName in cmpSlots) {
5423
+ for (const slotName in cmpSlots.slotAssignments) {
5352
5424
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
5353
- assert.isTrue(isArray$1(cmpSlots[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots[slotName])} for slot "${slotName}" in ${vm}.`);
5425
+ assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
5354
5426
  if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
5355
5427
  // TODO [#1297]: this should never really happen because the compiler should always validate
5356
5428
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
@@ -5847,7 +5919,9 @@ function createVM(elm, ctor, renderer, options) {
5847
5919
  velements: EmptyArray,
5848
5920
  cmpProps: create(null),
5849
5921
  cmpFields: create(null),
5850
- cmpSlots: create(null),
5922
+ cmpSlots: {
5923
+ slotAssignments: create(null)
5924
+ },
5851
5925
  oar: create(null),
5852
5926
  cmpTemplate: null,
5853
5927
  hydrated: Boolean(hydrated),
@@ -7256,7 +7330,7 @@ function getComponentConstructor(elm) {
7256
7330
  }
7257
7331
  return ctor;
7258
7332
  }
7259
- /* version: 2.26.2 */
7333
+ /* version: 2.28.0 */
7260
7334
 
7261
7335
  /*
7262
7336
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7530,10 +7604,12 @@ function createScopedRegistry() {
7530
7604
  const pendingRegistryForElement = new WeakMap();
7531
7605
  const definitionForConstructor = new WeakMap();
7532
7606
  const registeredUserCtors = new WeakSet();
7607
+ const registeredPivotCtors = new WeakSet();
7533
7608
  const pivotCtorByTag = new Map();
7534
7609
  const globalDefinitionsByTag = new Map();
7535
7610
  const globalDefinitionsByClass = new Map();
7536
7611
  const awaitingUpgrade = new Map();
7612
+ const pendingWhenDefinedCallbacks = new Map();
7537
7613
  const EMPTY_SET = new Set();
7538
7614
  function createDefinitionRecord(constructor) {
7539
7615
  var _a;
@@ -7639,6 +7715,7 @@ function createScopedRegistry() {
7639
7715
  }
7640
7716
  }
7641
7717
  PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7718
+ registeredPivotCtors.add(PivotCtor);
7642
7719
  return PivotCtor;
7643
7720
  }
7644
7721
  function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
@@ -7772,6 +7849,27 @@ function createScopedRegistry() {
7772
7849
  }
7773
7850
  return createDefinitionRecord(constructor);
7774
7851
  }
7852
+ // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7853
+ function createPendingWhenDefinedCallback(tagName) {
7854
+ return new Promise((resolve) => {
7855
+ let resolvers = pendingWhenDefinedCallbacks.get(tagName);
7856
+ if (isUndefined$1(resolvers)) {
7857
+ resolvers = [];
7858
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7859
+ }
7860
+ resolvers.push(resolve);
7861
+ });
7862
+ }
7863
+ // Call any pending `whenDefined()` callbacks
7864
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7865
+ const resolvers = pendingWhenDefinedCallbacks.get(tagName);
7866
+ if (!isUndefined$1(resolvers)) {
7867
+ for (const resolver of resolvers) {
7868
+ resolver(ctor);
7869
+ }
7870
+ }
7871
+ pendingWhenDefinedCallbacks.delete(tagName);
7872
+ }
7775
7873
  const { customElements: nativeRegistry } = window;
7776
7874
  const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7777
7875
  // patch for the global registry define mechanism
@@ -7826,6 +7924,8 @@ function createScopedRegistry() {
7826
7924
  }
7827
7925
  }
7828
7926
  }
7927
+ // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7928
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7829
7929
  };
7830
7930
  CustomElementRegistry.prototype.get = function get(tagName) {
7831
7931
  const NativeCtor = nativeGet.call(nativeRegistry, tagName);
@@ -7834,8 +7934,10 @@ function createScopedRegistry() {
7834
7934
  if (!isUndefined$1(definition)) {
7835
7935
  return definition.UserCtor; // defined by the patched custom elements registry
7836
7936
  }
7837
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7838
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7937
+ if (registeredPivotCtors.has(NativeCtor)) {
7938
+ return undefined; // pivot constructors should not be observable, return undefined
7939
+ }
7940
+ return NativeCtor; // constructor that existed before patching
7839
7941
  }
7840
7942
  };
7841
7943
  CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
@@ -7844,13 +7946,17 @@ function createScopedRegistry() {
7844
7946
  if (!isUndefined$1(definition)) {
7845
7947
  return definition.UserCtor;
7846
7948
  }
7847
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7848
7949
  // In this case, the custom element must have been defined before the registry patches
7849
7950
  // were applied. So return the non-pivot constructor
7850
7951
  if (isUndefined$1(NativeCtor)) {
7851
7952
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7852
7953
  // We can patch the correct behavior using customElements.get()
7853
- return nativeGet.call(nativeRegistry, tagName);
7954
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7955
+ }
7956
+ if (registeredPivotCtors.has(NativeCtor)) {
7957
+ // Pivot constructors should not be observable. Wait to resolve the promise
7958
+ // if a constructor is ever defined in userland
7959
+ return createPendingWhenDefinedCallback(tagName);
7854
7960
  }
7855
7961
  return NativeCtor;
7856
7962
  });
@@ -8080,7 +8186,7 @@ function rendererFactory(baseRenderer) {
8080
8186
  function isNull(obj) {
8081
8187
  return obj === null;
8082
8188
  }
8083
- /** version: 2.26.2 */
8189
+ /** version: 2.28.0 */
8084
8190
 
8085
8191
  /*
8086
8192
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8659,6 +8765,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
8659
8765
  });
8660
8766
  freeze(LightningElement);
8661
8767
  seal(LightningElement.prototype);
8662
- /* version: 2.26.2 */
8768
+ /* version: 2.28.0 */
8663
8769
 
8664
8770
  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, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };