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
@@ -49,7 +49,7 @@
49
49
  */
50
50
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
51
51
  const { isArray: isArray$1 } = Array;
52
- 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;
52
+ 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;
53
53
  const { fromCharCode: StringFromCharCode } = String;
54
54
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
55
55
  function isUndefined$1(obj) {
@@ -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.26.2";
308
+ const LWC_VERSION = "2.28.0";
309
309
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
310
- /** version: 2.26.2 */
310
+ /** version: 2.28.0 */
311
311
 
312
312
  /**
313
313
  * Copyright (C) 2018 salesforce.com, inc.
@@ -389,7 +389,7 @@
389
389
  patch$1(propName);
390
390
  }
391
391
  }
392
- /** version: 2.26.2 */
392
+ /** version: 2.28.0 */
393
393
 
394
394
  /**
395
395
  * Copyright (C) 2018 salesforce.com, inc.
@@ -469,7 +469,7 @@
469
469
  setFeatureFlag(name, value);
470
470
  }
471
471
  }
472
- /** version: 2.26.2 */
472
+ /** version: 2.28.0 */
473
473
 
474
474
  /*
475
475
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3692,6 +3692,9 @@
3692
3692
  function isVCustomElement(vnode) {
3693
3693
  return vnode.type === 3 /* VNodeType.CustomElement */;
3694
3694
  }
3695
+ function isVScopedSlotFragment(vnode) {
3696
+ return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3697
+ }
3695
3698
 
3696
3699
  /*
3697
3700
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4525,13 +4528,24 @@
4525
4528
  shadowMode
4526
4529
  } = vm;
4527
4530
 
4531
+ if (process.env.NODE_ENV !== 'production') {
4532
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4533
+ // component is a light DOM component. This is mainly to validate light dom parent running
4534
+ // in native shadow mode.
4535
+ if (renderMode !== 0
4536
+ /* RenderMode.Light */
4537
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4538
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4539
+ }
4540
+ }
4541
+
4528
4542
  if (shadowMode === 1
4529
4543
  /* ShadowMode.Synthetic */
4530
4544
  || renderMode === 0
4531
4545
  /* RenderMode.Light */
4532
4546
  ) {
4533
4547
  // slow path
4534
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4548
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4535
4549
 
4536
4550
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4537
4551
 
@@ -4567,13 +4581,19 @@
4567
4581
  return vm;
4568
4582
  }
4569
4583
 
4570
- function allocateInSlot(vm, children) {
4571
- var _a;
4584
+ function allocateInSlot(vm, children, owner) {
4585
+ var _a, _b;
4572
4586
 
4573
4587
  const {
4574
- cmpSlots: oldSlots
4588
+ cmpSlots: {
4589
+ slotAssignments: oldSlotsMapping
4590
+ }
4575
4591
  } = vm;
4576
- const cmpSlots = vm.cmpSlots = create(null);
4592
+ const cmpSlotsMapping = create(null);
4593
+ vm.cmpSlots = {
4594
+ owner,
4595
+ slotAssignments: cmpSlotsMapping
4596
+ };
4577
4597
 
4578
4598
  for (let i = 0, len = children.length; i < len; i += 1) {
4579
4599
  const vnode = children[i];
@@ -4585,19 +4605,21 @@
4585
4605
  let slotName = '';
4586
4606
 
4587
4607
  if (isVBaseElement(vnode)) {
4588
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4608
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4609
+ } else if (isVScopedSlotFragment(vnode)) {
4610
+ slotName = vnode.slotName;
4589
4611
  }
4590
4612
 
4591
- const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4613
+ const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4592
4614
  ArrayPush$1.call(vnodes, vnode);
4593
4615
  }
4594
4616
 
4595
4617
  if (isFalse(vm.isDirty)) {
4596
4618
  // We need to determine if the old allocation is really different from the new one
4597
4619
  // and mark the vm as dirty
4598
- const oldKeys = keys(oldSlots);
4620
+ const oldKeys = keys(oldSlotsMapping);
4599
4621
 
4600
- if (oldKeys.length !== keys(cmpSlots).length) {
4622
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4601
4623
  markComponentAsDirty(vm);
4602
4624
  return;
4603
4625
  }
@@ -4605,15 +4627,15 @@
4605
4627
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4606
4628
  const key = oldKeys[i];
4607
4629
 
4608
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4630
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4609
4631
  markComponentAsDirty(vm);
4610
4632
  return;
4611
4633
  }
4612
4634
 
4613
- const oldVNodes = oldSlots[key];
4614
- const vnodes = cmpSlots[key];
4635
+ const oldVNodes = oldSlotsMapping[key];
4636
+ const vnodes = cmpSlotsMapping[key];
4615
4637
 
4616
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4638
+ for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4617
4639
  if (oldVNodes[j] !== vnodes[j]) {
4618
4640
  markComponentAsDirty(vm);
4619
4641
  return;
@@ -4813,6 +4835,18 @@
4813
4835
  function addVNodeToChildLWC(vnode) {
4814
4836
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4815
4837
  }
4838
+ // [s]coped [s]lot [f]actory
4839
+ function ssf(slotName, factory) {
4840
+ return {
4841
+ type: 6 /* VNodeType.ScopedSlotFragment */,
4842
+ factory,
4843
+ owner: getVMBeingRendered(),
4844
+ elm: undefined,
4845
+ sel: undefined,
4846
+ key: undefined,
4847
+ slotName,
4848
+ };
4849
+ }
4816
4850
  // [st]atic node
4817
4851
  function st(fragment, key) {
4818
4852
  return {
@@ -4896,9 +4930,46 @@
4896
4930
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
4897
4931
  }
4898
4932
  if (!isUndefined$1(slotset) &&
4899
- !isUndefined$1(slotset[slotName]) &&
4900
- slotset[slotName].length !== 0) {
4901
- children = slotset[slotName];
4933
+ !isUndefined$1(slotset.slotAssignments) &&
4934
+ !isUndefined$1(slotset.slotAssignments[slotName]) &&
4935
+ slotset.slotAssignments[slotName].length !== 0) {
4936
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4937
+ if (vnode) {
4938
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4939
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4940
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4941
+ // Check if slot types of parent and child are matching
4942
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4943
+ if (process.env.NODE_ENV !== 'production') {
4944
+ 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);
4945
+ }
4946
+ // Ignore slot content from parent
4947
+ return accumulator;
4948
+ }
4949
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4950
+ if (assignedNodeIsScopedSlot) {
4951
+ const vmBeingRenderedInception = getVMBeingRendered();
4952
+ let scopedSlotChildren = [];
4953
+ // Evaluate in the scope of the slot content's owner
4954
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4955
+ // undefined is for root components, but root components cannot accept slotted content
4956
+ setVMBeingRendered(slotset.owner);
4957
+ try {
4958
+ scopedSlotChildren = vnode.factory(data.slotData);
4959
+ }
4960
+ finally {
4961
+ setVMBeingRendered(vmBeingRenderedInception);
4962
+ }
4963
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4964
+ }
4965
+ else {
4966
+ // If the slot content is standard type, the content is static, no additional
4967
+ // processing needed on the vnode
4968
+ return ArrayConcat$1.call(accumulator, vnode);
4969
+ }
4970
+ }
4971
+ return accumulator;
4972
+ }, []);
4902
4973
  }
4903
4974
  const vmBeingRendered = getVMBeingRendered();
4904
4975
  const { renderMode, shadowMode } = vmBeingRendered;
@@ -5218,6 +5289,7 @@
5218
5289
  gid,
5219
5290
  fid,
5220
5291
  shc,
5292
+ ssf,
5221
5293
  });
5222
5294
 
5223
5295
  /*
@@ -5354,9 +5426,9 @@
5354
5426
  }
5355
5427
  const { cmpSlots } = vm;
5356
5428
  const { slots = EmptyArray } = html;
5357
- for (const slotName in cmpSlots) {
5429
+ for (const slotName in cmpSlots.slotAssignments) {
5358
5430
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
5359
- 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}.`);
5431
+ 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}.`);
5360
5432
  if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
5361
5433
  // TODO [#1297]: this should never really happen because the compiler should always validate
5362
5434
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
@@ -5853,7 +5925,9 @@
5853
5925
  velements: EmptyArray,
5854
5926
  cmpProps: create(null),
5855
5927
  cmpFields: create(null),
5856
- cmpSlots: create(null),
5928
+ cmpSlots: {
5929
+ slotAssignments: create(null)
5930
+ },
5857
5931
  oar: create(null),
5858
5932
  cmpTemplate: null,
5859
5933
  hydrated: Boolean(hydrated),
@@ -7262,7 +7336,7 @@
7262
7336
  }
7263
7337
  return ctor;
7264
7338
  }
7265
- /* version: 2.26.2 */
7339
+ /* version: 2.28.0 */
7266
7340
 
7267
7341
  /*
7268
7342
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7536,10 +7610,12 @@
7536
7610
  const pendingRegistryForElement = new WeakMap();
7537
7611
  const definitionForConstructor = new WeakMap();
7538
7612
  const registeredUserCtors = new WeakSet();
7613
+ const registeredPivotCtors = new WeakSet();
7539
7614
  const pivotCtorByTag = new Map();
7540
7615
  const globalDefinitionsByTag = new Map();
7541
7616
  const globalDefinitionsByClass = new Map();
7542
7617
  const awaitingUpgrade = new Map();
7618
+ const pendingWhenDefinedCallbacks = new Map();
7543
7619
  const EMPTY_SET = new Set();
7544
7620
  function createDefinitionRecord(constructor) {
7545
7621
  var _a;
@@ -7645,6 +7721,7 @@
7645
7721
  }
7646
7722
  }
7647
7723
  PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7724
+ registeredPivotCtors.add(PivotCtor);
7648
7725
  return PivotCtor;
7649
7726
  }
7650
7727
  function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
@@ -7778,6 +7855,27 @@
7778
7855
  }
7779
7856
  return createDefinitionRecord(constructor);
7780
7857
  }
7858
+ // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7859
+ function createPendingWhenDefinedCallback(tagName) {
7860
+ return new Promise((resolve) => {
7861
+ let resolvers = pendingWhenDefinedCallbacks.get(tagName);
7862
+ if (isUndefined$1(resolvers)) {
7863
+ resolvers = [];
7864
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7865
+ }
7866
+ resolvers.push(resolve);
7867
+ });
7868
+ }
7869
+ // Call any pending `whenDefined()` callbacks
7870
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7871
+ const resolvers = pendingWhenDefinedCallbacks.get(tagName);
7872
+ if (!isUndefined$1(resolvers)) {
7873
+ for (const resolver of resolvers) {
7874
+ resolver(ctor);
7875
+ }
7876
+ }
7877
+ pendingWhenDefinedCallbacks.delete(tagName);
7878
+ }
7781
7879
  const { customElements: nativeRegistry } = window;
7782
7880
  const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7783
7881
  // patch for the global registry define mechanism
@@ -7832,6 +7930,8 @@
7832
7930
  }
7833
7931
  }
7834
7932
  }
7933
+ // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7934
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7835
7935
  };
7836
7936
  CustomElementRegistry.prototype.get = function get(tagName) {
7837
7937
  const NativeCtor = nativeGet.call(nativeRegistry, tagName);
@@ -7840,8 +7940,10 @@
7840
7940
  if (!isUndefined$1(definition)) {
7841
7941
  return definition.UserCtor; // defined by the patched custom elements registry
7842
7942
  }
7843
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7844
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7943
+ if (registeredPivotCtors.has(NativeCtor)) {
7944
+ return undefined; // pivot constructors should not be observable, return undefined
7945
+ }
7946
+ return NativeCtor; // constructor that existed before patching
7845
7947
  }
7846
7948
  };
7847
7949
  CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
@@ -7850,13 +7952,17 @@
7850
7952
  if (!isUndefined$1(definition)) {
7851
7953
  return definition.UserCtor;
7852
7954
  }
7853
- // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7854
7955
  // In this case, the custom element must have been defined before the registry patches
7855
7956
  // were applied. So return the non-pivot constructor
7856
7957
  if (isUndefined$1(NativeCtor)) {
7857
7958
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7858
7959
  // We can patch the correct behavior using customElements.get()
7859
- return nativeGet.call(nativeRegistry, tagName);
7960
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7961
+ }
7962
+ if (registeredPivotCtors.has(NativeCtor)) {
7963
+ // Pivot constructors should not be observable. Wait to resolve the promise
7964
+ // if a constructor is ever defined in userland
7965
+ return createPendingWhenDefinedCallback(tagName);
7860
7966
  }
7861
7967
  return NativeCtor;
7862
7968
  });
@@ -8086,7 +8192,7 @@
8086
8192
  function isNull(obj) {
8087
8193
  return obj === null;
8088
8194
  }
8089
- /** version: 2.26.2 */
8195
+ /** version: 2.28.0 */
8090
8196
 
8091
8197
  /*
8092
8198
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8665,7 +8771,7 @@
8665
8771
  });
8666
8772
  freeze(LightningElement);
8667
8773
  seal(LightningElement.prototype);
8668
- /* version: 2.26.2 */
8774
+ /* version: 2.28.0 */
8669
8775
 
8670
8776
  exports.LightningElement = LightningElement;
8671
8777
  exports.__unstable__ProfilerControl = profilerControl;