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
@@ -46,7 +46,7 @@ var LWC = (function (exports) {
46
46
  */
47
47
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
48
48
  const { isArray: isArray$1 } = Array;
49
- 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;
49
+ 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;
50
50
  const { fromCharCode: StringFromCharCode } = String;
51
51
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
52
52
  function isUndefined$1(obj) {
@@ -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.26.2";
305
+ const LWC_VERSION = "2.28.0";
306
306
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
307
- /** version: 2.26.2 */
307
+ /** version: 2.28.0 */
308
308
 
309
309
  /**
310
310
  * Copyright (C) 2018 salesforce.com, inc.
@@ -386,7 +386,7 @@ var LWC = (function (exports) {
386
386
  patch$1(propName);
387
387
  }
388
388
  }
389
- /** version: 2.26.2 */
389
+ /** version: 2.28.0 */
390
390
 
391
391
  /**
392
392
  * Copyright (C) 2018 salesforce.com, inc.
@@ -466,7 +466,7 @@ var LWC = (function (exports) {
466
466
  setFeatureFlag(name, value);
467
467
  }
468
468
  }
469
- /** version: 2.26.2 */
469
+ /** version: 2.28.0 */
470
470
 
471
471
  /*
472
472
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3689,6 +3689,9 @@ var LWC = (function (exports) {
3689
3689
  function isVCustomElement(vnode) {
3690
3690
  return vnode.type === 3 /* VNodeType.CustomElement */;
3691
3691
  }
3692
+ function isVScopedSlotFragment(vnode) {
3693
+ return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3694
+ }
3692
3695
 
3693
3696
  /*
3694
3697
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4522,13 +4525,24 @@ var LWC = (function (exports) {
4522
4525
  shadowMode
4523
4526
  } = vm;
4524
4527
 
4528
+ if (process.env.NODE_ENV !== 'production') {
4529
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4530
+ // component is a light DOM component. This is mainly to validate light dom parent running
4531
+ // in native shadow mode.
4532
+ if (renderMode !== 0
4533
+ /* RenderMode.Light */
4534
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4535
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4536
+ }
4537
+ }
4538
+
4525
4539
  if (shadowMode === 1
4526
4540
  /* ShadowMode.Synthetic */
4527
4541
  || renderMode === 0
4528
4542
  /* RenderMode.Light */
4529
4543
  ) {
4530
4544
  // slow path
4531
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4545
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4532
4546
 
4533
4547
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4534
4548
 
@@ -4564,13 +4578,19 @@ var LWC = (function (exports) {
4564
4578
  return vm;
4565
4579
  }
4566
4580
 
4567
- function allocateInSlot(vm, children) {
4568
- var _a;
4581
+ function allocateInSlot(vm, children, owner) {
4582
+ var _a, _b;
4569
4583
 
4570
4584
  const {
4571
- cmpSlots: oldSlots
4585
+ cmpSlots: {
4586
+ slotAssignments: oldSlotsMapping
4587
+ }
4572
4588
  } = vm;
4573
- const cmpSlots = vm.cmpSlots = create(null);
4589
+ const cmpSlotsMapping = create(null);
4590
+ vm.cmpSlots = {
4591
+ owner,
4592
+ slotAssignments: cmpSlotsMapping
4593
+ };
4574
4594
 
4575
4595
  for (let i = 0, len = children.length; i < len; i += 1) {
4576
4596
  const vnode = children[i];
@@ -4582,19 +4602,21 @@ var LWC = (function (exports) {
4582
4602
  let slotName = '';
4583
4603
 
4584
4604
  if (isVBaseElement(vnode)) {
4585
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4605
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4606
+ } else if (isVScopedSlotFragment(vnode)) {
4607
+ slotName = vnode.slotName;
4586
4608
  }
4587
4609
 
4588
- const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4610
+ const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4589
4611
  ArrayPush$1.call(vnodes, vnode);
4590
4612
  }
4591
4613
 
4592
4614
  if (isFalse(vm.isDirty)) {
4593
4615
  // We need to determine if the old allocation is really different from the new one
4594
4616
  // and mark the vm as dirty
4595
- const oldKeys = keys(oldSlots);
4617
+ const oldKeys = keys(oldSlotsMapping);
4596
4618
 
4597
- if (oldKeys.length !== keys(cmpSlots).length) {
4619
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4598
4620
  markComponentAsDirty(vm);
4599
4621
  return;
4600
4622
  }
@@ -4602,15 +4624,15 @@ var LWC = (function (exports) {
4602
4624
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4603
4625
  const key = oldKeys[i];
4604
4626
 
4605
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4627
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4606
4628
  markComponentAsDirty(vm);
4607
4629
  return;
4608
4630
  }
4609
4631
 
4610
- const oldVNodes = oldSlots[key];
4611
- const vnodes = cmpSlots[key];
4632
+ const oldVNodes = oldSlotsMapping[key];
4633
+ const vnodes = cmpSlotsMapping[key];
4612
4634
 
4613
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4635
+ for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4614
4636
  if (oldVNodes[j] !== vnodes[j]) {
4615
4637
  markComponentAsDirty(vm);
4616
4638
  return;
@@ -4810,6 +4832,18 @@ var LWC = (function (exports) {
4810
4832
  function addVNodeToChildLWC(vnode) {
4811
4833
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4812
4834
  }
4835
+ // [s]coped [s]lot [f]actory
4836
+ function ssf(slotName, factory) {
4837
+ return {
4838
+ type: 6 /* VNodeType.ScopedSlotFragment */,
4839
+ factory,
4840
+ owner: getVMBeingRendered(),
4841
+ elm: undefined,
4842
+ sel: undefined,
4843
+ key: undefined,
4844
+ slotName,
4845
+ };
4846
+ }
4813
4847
  // [st]atic node
4814
4848
  function st(fragment, key) {
4815
4849
  return {
@@ -4893,9 +4927,46 @@ var LWC = (function (exports) {
4893
4927
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
4894
4928
  }
4895
4929
  if (!isUndefined$1(slotset) &&
4896
- !isUndefined$1(slotset[slotName]) &&
4897
- slotset[slotName].length !== 0) {
4898
- children = slotset[slotName];
4930
+ !isUndefined$1(slotset.slotAssignments) &&
4931
+ !isUndefined$1(slotset.slotAssignments[slotName]) &&
4932
+ slotset.slotAssignments[slotName].length !== 0) {
4933
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4934
+ if (vnode) {
4935
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4936
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4937
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4938
+ // Check if slot types of parent and child are matching
4939
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4940
+ if (process.env.NODE_ENV !== 'production') {
4941
+ 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);
4942
+ }
4943
+ // Ignore slot content from parent
4944
+ return accumulator;
4945
+ }
4946
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4947
+ if (assignedNodeIsScopedSlot) {
4948
+ const vmBeingRenderedInception = getVMBeingRendered();
4949
+ let scopedSlotChildren = [];
4950
+ // Evaluate in the scope of the slot content's owner
4951
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4952
+ // undefined is for root components, but root components cannot accept slotted content
4953
+ setVMBeingRendered(slotset.owner);
4954
+ try {
4955
+ scopedSlotChildren = vnode.factory(data.slotData);
4956
+ }
4957
+ finally {
4958
+ setVMBeingRendered(vmBeingRenderedInception);
4959
+ }
4960
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4961
+ }
4962
+ else {
4963
+ // If the slot content is standard type, the content is static, no additional
4964
+ // processing needed on the vnode
4965
+ return ArrayConcat$1.call(accumulator, vnode);
4966
+ }
4967
+ }
4968
+ return accumulator;
4969
+ }, []);
4899
4970
  }
4900
4971
  const vmBeingRendered = getVMBeingRendered();
4901
4972
  const { renderMode, shadowMode } = vmBeingRendered;
@@ -5215,6 +5286,7 @@ var LWC = (function (exports) {
5215
5286
  gid,
5216
5287
  fid,
5217
5288
  shc,
5289
+ ssf,
5218
5290
  });
5219
5291
 
5220
5292
  /*
@@ -5351,9 +5423,9 @@ var LWC = (function (exports) {
5351
5423
  }
5352
5424
  const { cmpSlots } = vm;
5353
5425
  const { slots = EmptyArray } = html;
5354
- for (const slotName in cmpSlots) {
5426
+ for (const slotName in cmpSlots.slotAssignments) {
5355
5427
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
5356
- 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}.`);
5428
+ 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}.`);
5357
5429
  if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
5358
5430
  // TODO [#1297]: this should never really happen because the compiler should always validate
5359
5431
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
@@ -5850,7 +5922,9 @@ var LWC = (function (exports) {
5850
5922
  velements: EmptyArray,
5851
5923
  cmpProps: create(null),
5852
5924
  cmpFields: create(null),
5853
- cmpSlots: create(null),
5925
+ cmpSlots: {
5926
+ slotAssignments: create(null)
5927
+ },
5854
5928
  oar: create(null),
5855
5929
  cmpTemplate: null,
5856
5930
  hydrated: Boolean(hydrated),
@@ -7259,7 +7333,7 @@ var LWC = (function (exports) {
7259
7333
  }
7260
7334
  return ctor;
7261
7335
  }
7262
- /* version: 2.26.2 */
7336
+ /* version: 2.28.0 */
7263
7337
 
7264
7338
  /*
7265
7339
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7533,10 +7607,12 @@ var LWC = (function (exports) {
7533
7607
  const pendingRegistryForElement = new WeakMap();
7534
7608
  const definitionForConstructor = new WeakMap();
7535
7609
  const registeredUserCtors = new WeakSet();
7610
+ const registeredPivotCtors = new WeakSet();
7536
7611
  const pivotCtorByTag = new Map();
7537
7612
  const globalDefinitionsByTag = new Map();
7538
7613
  const globalDefinitionsByClass = new Map();
7539
7614
  const awaitingUpgrade = new Map();
7615
+ const pendingWhenDefinedCallbacks = new Map();
7540
7616
  const EMPTY_SET = new Set();
7541
7617
  function createDefinitionRecord(constructor) {
7542
7618
  var _a;
@@ -7642,6 +7718,7 @@ var LWC = (function (exports) {
7642
7718
  }
7643
7719
  }
7644
7720
  PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7721
+ registeredPivotCtors.add(PivotCtor);
7645
7722
  return PivotCtor;
7646
7723
  }
7647
7724
  function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
@@ -7775,6 +7852,27 @@ var LWC = (function (exports) {
7775
7852
  }
7776
7853
  return createDefinitionRecord(constructor);
7777
7854
  }
7855
+ // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7856
+ function createPendingWhenDefinedCallback(tagName) {
7857
+ return new Promise((resolve) => {
7858
+ let resolvers = pendingWhenDefinedCallbacks.get(tagName);
7859
+ if (isUndefined$1(resolvers)) {
7860
+ resolvers = [];
7861
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7862
+ }
7863
+ resolvers.push(resolve);
7864
+ });
7865
+ }
7866
+ // Call any pending `whenDefined()` callbacks
7867
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7868
+ const resolvers = pendingWhenDefinedCallbacks.get(tagName);
7869
+ if (!isUndefined$1(resolvers)) {
7870
+ for (const resolver of resolvers) {
7871
+ resolver(ctor);
7872
+ }
7873
+ }
7874
+ pendingWhenDefinedCallbacks.delete(tagName);
7875
+ }
7778
7876
  const { customElements: nativeRegistry } = window;
7779
7877
  const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7780
7878
  // patch for the global registry define mechanism
@@ -7829,6 +7927,8 @@ var LWC = (function (exports) {
7829
7927
  }
7830
7928
  }
7831
7929
  }
7930
+ // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7931
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7832
7932
  };
7833
7933
  CustomElementRegistry.prototype.get = function get(tagName) {
7834
7934
  const NativeCtor = nativeGet.call(nativeRegistry, tagName);
@@ -7837,8 +7937,10 @@ var LWC = (function (exports) {
7837
7937
  if (!isUndefined$1(definition)) {
7838
7938
  return definition.UserCtor; // defined by the patched custom elements registry
7839
7939
  }
7840
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7841
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7940
+ if (registeredPivotCtors.has(NativeCtor)) {
7941
+ return undefined; // pivot constructors should not be observable, return undefined
7942
+ }
7943
+ return NativeCtor; // constructor that existed before patching
7842
7944
  }
7843
7945
  };
7844
7946
  CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
@@ -7847,13 +7949,17 @@ var LWC = (function (exports) {
7847
7949
  if (!isUndefined$1(definition)) {
7848
7950
  return definition.UserCtor;
7849
7951
  }
7850
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7851
7952
  // In this case, the custom element must have been defined before the registry patches
7852
7953
  // were applied. So return the non-pivot constructor
7853
7954
  if (isUndefined$1(NativeCtor)) {
7854
7955
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7855
7956
  // We can patch the correct behavior using customElements.get()
7856
- return nativeGet.call(nativeRegistry, tagName);
7957
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7958
+ }
7959
+ if (registeredPivotCtors.has(NativeCtor)) {
7960
+ // Pivot constructors should not be observable. Wait to resolve the promise
7961
+ // if a constructor is ever defined in userland
7962
+ return createPendingWhenDefinedCallback(tagName);
7857
7963
  }
7858
7964
  return NativeCtor;
7859
7965
  });
@@ -8083,7 +8189,7 @@ var LWC = (function (exports) {
8083
8189
  function isNull(obj) {
8084
8190
  return obj === null;
8085
8191
  }
8086
- /** version: 2.26.2 */
8192
+ /** version: 2.28.0 */
8087
8193
 
8088
8194
  /*
8089
8195
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8662,7 +8768,7 @@ var LWC = (function (exports) {
8662
8768
  });
8663
8769
  freeze(LightningElement);
8664
8770
  seal(LightningElement.prototype);
8665
- /* version: 2.26.2 */
8771
+ /* version: 2.28.0 */
8666
8772
 
8667
8773
  exports.LightningElement = LightningElement;
8668
8774
  exports.__unstable__ProfilerControl = profilerControl;