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
@@ -123,6 +123,7 @@
123
123
  setPrototypeOf = Object.setPrototypeOf;
124
124
  var isArray$1 = Array.isArray;
125
125
  var _Array$prototype = Array.prototype,
126
+ ArrayConcat$1 = _Array$prototype.concat,
126
127
  ArrayFilter = _Array$prototype.filter,
127
128
  ArrayIndexOf = _Array$prototype.indexOf,
128
129
  ArrayJoin = _Array$prototype.join,
@@ -350,7 +351,7 @@
350
351
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
351
352
  return attributeName;
352
353
  }
353
- /** version: 2.26.2 */
354
+ /** version: 2.28.0 */
354
355
 
355
356
  /**
356
357
  * Copyright (C) 2018 salesforce.com, inc.
@@ -444,7 +445,7 @@
444
445
  patch$1(propName);
445
446
  }
446
447
  }
447
- /** version: 2.26.2 */
448
+ /** version: 2.28.0 */
448
449
 
449
450
  /**
450
451
  * Copyright (C) 2018 salesforce.com, inc.
@@ -3297,6 +3298,12 @@
3297
3298
  /* VNodeType.CustomElement */
3298
3299
  ;
3299
3300
  }
3301
+
3302
+ function isVScopedSlotFragment(vnode) {
3303
+ return vnode.type === 6
3304
+ /* VNodeType.ScopedSlotFragment */
3305
+ ;
3306
+ }
3300
3307
  /*
3301
3308
  * Copyright (c) 2018, salesforce.com, inc.
3302
3309
  * All rights reserved.
@@ -4081,7 +4088,7 @@
4081
4088
  /* RenderMode.Light */
4082
4089
  ) {
4083
4090
  // slow path
4084
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4091
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4085
4092
 
4086
4093
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4087
4094
 
@@ -4111,11 +4118,15 @@
4111
4118
  return vm;
4112
4119
  }
4113
4120
 
4114
- function allocateInSlot(vm, children) {
4115
- var _a;
4121
+ function allocateInSlot(vm, children, owner) {
4122
+ var _a, _b;
4116
4123
 
4117
- var oldSlots = vm.cmpSlots;
4118
- var cmpSlots = vm.cmpSlots = create(null);
4124
+ var oldSlotsMapping = vm.cmpSlots.slotAssignments;
4125
+ var cmpSlotsMapping = create(null);
4126
+ vm.cmpSlots = {
4127
+ owner: owner,
4128
+ slotAssignments: cmpSlotsMapping
4129
+ };
4119
4130
 
4120
4131
  for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
4121
4132
  var vnode = children[_i15];
@@ -4127,19 +4138,21 @@
4127
4138
  var slotName = '';
4128
4139
 
4129
4140
  if (isVBaseElement(vnode)) {
4130
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4141
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4142
+ } else if (isVScopedSlotFragment(vnode)) {
4143
+ slotName = vnode.slotName;
4131
4144
  }
4132
4145
 
4133
- var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4146
+ var vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4134
4147
  ArrayPush$1.call(vnodes, vnode);
4135
4148
  }
4136
4149
 
4137
4150
  if (isFalse(vm.isDirty)) {
4138
4151
  // We need to determine if the old allocation is really different from the new one
4139
4152
  // and mark the vm as dirty
4140
- var oldKeys = keys(oldSlots);
4153
+ var oldKeys = keys(oldSlotsMapping);
4141
4154
 
4142
- if (oldKeys.length !== keys(cmpSlots).length) {
4155
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4143
4156
  markComponentAsDirty(vm);
4144
4157
  return;
4145
4158
  }
@@ -4147,15 +4160,15 @@
4147
4160
  for (var _i16 = 0, _len4 = oldKeys.length; _i16 < _len4; _i16 += 1) {
4148
4161
  var key = oldKeys[_i16];
4149
4162
 
4150
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4163
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4151
4164
  markComponentAsDirty(vm);
4152
4165
  return;
4153
4166
  }
4154
4167
 
4155
- var oldVNodes = oldSlots[key];
4156
- var _vnodes = cmpSlots[key];
4168
+ var oldVNodes = oldSlotsMapping[key];
4169
+ var _vnodes = cmpSlotsMapping[key];
4157
4170
 
4158
- for (var j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4171
+ for (var j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4159
4172
  if (oldVNodes[j] !== _vnodes[j]) {
4160
4173
  markComponentAsDirty(vm);
4161
4174
  return;
@@ -4354,6 +4367,21 @@
4354
4367
 
4355
4368
  function addVNodeToChildLWC(vnode) {
4356
4369
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4370
+ } // [s]coped [s]lot [f]actory
4371
+
4372
+
4373
+ function ssf(slotName, factory) {
4374
+ return {
4375
+ type: 6
4376
+ /* VNodeType.ScopedSlotFragment */
4377
+ ,
4378
+ factory: factory,
4379
+ owner: getVMBeingRendered(),
4380
+ elm: undefined,
4381
+ sel: undefined,
4382
+ key: undefined,
4383
+ slotName: slotName
4384
+ };
4357
4385
  } // [st]atic node
4358
4386
 
4359
4387
 
@@ -4424,8 +4452,44 @@
4424
4452
 
4425
4453
  function s(slotName, data, children, slotset) {
4426
4454
 
4427
- if (!isUndefined$1(slotset) && !isUndefined$1(slotset[slotName]) && slotset[slotName].length !== 0) {
4428
- children = slotset[slotName];
4455
+ if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
4456
+ children = slotset.slotAssignments[slotName].reduce(function (accumulator, vnode) {
4457
+ if (vnode) {
4458
+ var assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode); // The only sniff test for a scoped <slot> element is the presence of `slotData`
4459
+
4460
+ var isScopedSlotElement = !isUndefined$1(data.slotData); // Check if slot types of parent and child are matching
4461
+
4462
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4463
+
4464
+
4465
+ return accumulator;
4466
+ } // If the passed slot content is factory, evaluate it and add the produced vnodes
4467
+
4468
+
4469
+ if (assignedNodeIsScopedSlot) {
4470
+ var vmBeingRenderedInception = getVMBeingRendered();
4471
+ var scopedSlotChildren = []; // Evaluate in the scope of the slot content's owner
4472
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4473
+ // undefined is for root components, but root components cannot accept slotted content
4474
+
4475
+ setVMBeingRendered(slotset.owner);
4476
+
4477
+ try {
4478
+ scopedSlotChildren = vnode.factory(data.slotData);
4479
+ } finally {
4480
+ setVMBeingRendered(vmBeingRenderedInception);
4481
+ }
4482
+
4483
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4484
+ } else {
4485
+ // If the slot content is standard type, the content is static, no additional
4486
+ // processing needed on the vnode
4487
+ return ArrayConcat$1.call(accumulator, vnode);
4488
+ }
4489
+ }
4490
+
4491
+ return accumulator;
4492
+ }, []);
4429
4493
  }
4430
4494
 
4431
4495
  var vmBeingRendered = getVMBeingRendered();
@@ -4742,7 +4806,8 @@
4742
4806
  st: st,
4743
4807
  gid: gid,
4744
4808
  fid: fid,
4745
- shc: shc
4809
+ shc: shc,
4810
+ ssf: ssf
4746
4811
  });
4747
4812
  /** Indicates if operations should be logged by the profiler. */
4748
4813
 
@@ -5353,7 +5418,9 @@
5353
5418
  velements: EmptyArray,
5354
5419
  cmpProps: create(null),
5355
5420
  cmpFields: create(null),
5356
- cmpSlots: create(null),
5421
+ cmpSlots: {
5422
+ slotAssignments: create(null)
5423
+ },
5357
5424
  oar: create(null),
5358
5425
  cmpTemplate: null,
5359
5426
  hydrated: Boolean(hydrated),
@@ -6669,7 +6736,7 @@
6669
6736
 
6670
6737
  return ctor;
6671
6738
  }
6672
- /* version: 2.26.2 */
6739
+ /* version: 2.28.0 */
6673
6740
 
6674
6741
  /*
6675
6742
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6995,10 +7062,12 @@
6995
7062
  var pendingRegistryForElement = new WeakMap();
6996
7063
  var definitionForConstructor = new WeakMap();
6997
7064
  var registeredUserCtors = new WeakSet();
7065
+ var registeredPivotCtors = new WeakSet();
6998
7066
  var pivotCtorByTag = new Map();
6999
7067
  var globalDefinitionsByTag = new Map();
7000
7068
  var globalDefinitionsByClass = new Map();
7001
7069
  var awaitingUpgrade = new Map();
7070
+ var pendingWhenDefinedCallbacks = new Map();
7002
7071
  var EMPTY_SET = new Set();
7003
7072
 
7004
7073
  function createDefinitionRecord(constructor) {
@@ -7140,6 +7209,7 @@
7140
7209
  }(NativeHTMLElement);
7141
7210
 
7142
7211
  PivotCtor.observedAttributes = _toConsumableArray(registeredDefinition.observedAttributes);
7212
+ registeredPivotCtors.add(PivotCtor);
7143
7213
  return PivotCtor;
7144
7214
  }
7145
7215
 
@@ -7290,6 +7360,43 @@
7290
7360
  }
7291
7361
 
7292
7362
  return createDefinitionRecord(constructor);
7363
+ } // Defer a `whenDefined()` callback until an externally-visible custom element is defined
7364
+
7365
+
7366
+ function createPendingWhenDefinedCallback(tagName) {
7367
+ return new Promise(function (resolve) {
7368
+ var resolvers = pendingWhenDefinedCallbacks.get(tagName);
7369
+
7370
+ if (isUndefined$1(resolvers)) {
7371
+ resolvers = [];
7372
+ pendingWhenDefinedCallbacks.set(tagName, resolvers);
7373
+ }
7374
+
7375
+ resolvers.push(resolve);
7376
+ });
7377
+ } // Call any pending `whenDefined()` callbacks
7378
+
7379
+
7380
+ function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7381
+ var resolvers = pendingWhenDefinedCallbacks.get(tagName);
7382
+
7383
+ if (!isUndefined$1(resolvers)) {
7384
+ var _iterator6 = _createForOfIteratorHelper(resolvers),
7385
+ _step6;
7386
+
7387
+ try {
7388
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
7389
+ var resolver = _step6.value;
7390
+ resolver(ctor);
7391
+ }
7392
+ } catch (err) {
7393
+ _iterator6.e(err);
7394
+ } finally {
7395
+ _iterator6.f();
7396
+ }
7397
+ }
7398
+
7399
+ pendingWhenDefinedCallbacks.delete(tagName);
7293
7400
  }
7294
7401
 
7295
7402
  var _window2 = window,
@@ -7344,12 +7451,12 @@
7344
7451
  if (!isUndefined$1(awaiting)) {
7345
7452
  awaitingUpgrade.delete(tagName);
7346
7453
 
7347
- var _iterator6 = _createForOfIteratorHelper(awaiting),
7348
- _step6;
7454
+ var _iterator7 = _createForOfIteratorHelper(awaiting),
7455
+ _step7;
7349
7456
 
7350
7457
  try {
7351
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
7352
- var element = _step6.value;
7458
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
7459
+ var element = _step7.value;
7353
7460
  var registeredDefinition = pendingRegistryForElement.get(element); // At this point, registeredDefinition should never be undefined because awaitingUpgrade
7354
7461
  // is only populated when we haven't run internalUpgrade yet, and we only populate
7355
7462
  // pendingRegistryForElement when internalUpgrade hasn't run yet.
@@ -7361,11 +7468,14 @@
7361
7468
  }
7362
7469
  }
7363
7470
  } catch (err) {
7364
- _iterator6.e(err);
7471
+ _iterator7.e(err);
7365
7472
  } finally {
7366
- _iterator6.f();
7473
+ _iterator7.f();
7367
7474
  }
7368
- }
7475
+ } // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
7476
+
7477
+
7478
+ flushPendingWhenDefinedCallbacks(tagName, constructor);
7369
7479
  };
7370
7480
 
7371
7481
  CustomElementRegistry.prototype.get = function get(tagName) {
@@ -7376,10 +7486,13 @@
7376
7486
 
7377
7487
  if (!isUndefined$1(definition)) {
7378
7488
  return definition.UserCtor; // defined by the patched custom elements registry
7379
- } // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7489
+ }
7380
7490
 
7491
+ if (registeredPivotCtors.has(NativeCtor)) {
7492
+ return undefined; // pivot constructors should not be observable, return undefined
7493
+ }
7381
7494
 
7382
- return NativeCtor; // return the pivot constructor or constructor that existed before patching
7495
+ return NativeCtor; // constructor that existed before patching
7383
7496
  }
7384
7497
  };
7385
7498
 
@@ -7389,15 +7502,20 @@
7389
7502
 
7390
7503
  if (!isUndefined$1(definition)) {
7391
7504
  return definition.UserCtor;
7392
- } // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7393
- // In this case, the custom element must have been defined before the registry patches
7505
+ } // In this case, the custom element must have been defined before the registry patches
7394
7506
  // were applied. So return the non-pivot constructor
7395
7507
 
7396
7508
 
7397
7509
  if (isUndefined$1(NativeCtor)) {
7398
7510
  // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7399
7511
  // We can patch the correct behavior using customElements.get()
7400
- return nativeGet.call(nativeRegistry, tagName);
7512
+ NativeCtor = nativeGet.call(nativeRegistry, tagName);
7513
+ }
7514
+
7515
+ if (registeredPivotCtors.has(NativeCtor)) {
7516
+ // Pivot constructors should not be observable. Wait to resolve the promise
7517
+ // if a constructor is ever defined in userland
7518
+ return createPendingWhenDefinedCallback(tagName);
7401
7519
  }
7402
7520
 
7403
7521
  return NativeCtor;
@@ -7661,7 +7779,7 @@
7661
7779
  function isNull(obj) {
7662
7780
  return obj === null;
7663
7781
  }
7664
- /** version: 2.26.2 */
7782
+ /** version: 2.28.0 */
7665
7783
 
7666
7784
  /*
7667
7785
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7729,18 +7847,18 @@
7729
7847
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
7730
7848
 
7731
7849
  if (!isUndefined(wrapperTags)) {
7732
- var _iterator7 = _createForOfIteratorHelper(wrapperTags),
7733
- _step7;
7850
+ var _iterator8 = _createForOfIteratorHelper(wrapperTags),
7851
+ _step8;
7734
7852
 
7735
7853
  try {
7736
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
7737
- var wrapperTag = _step7.value;
7854
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
7855
+ var wrapperTag = _step8.value;
7738
7856
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
7739
7857
  }
7740
7858
  } catch (err) {
7741
- _iterator7.e(err);
7859
+ _iterator8.e(err);
7742
7860
  } finally {
7743
- _iterator7.f();
7861
+ _iterator8.f();
7744
7862
  }
7745
7863
  } // For IE11, the document title must not be undefined, but it can be an empty string
7746
7864
  // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
@@ -8321,7 +8439,7 @@
8321
8439
  });
8322
8440
  freeze(LightningElement);
8323
8441
  seal(LightningElement.prototype);
8324
- /* version: 2.26.2 */
8442
+ /* version: 2.28.0 */
8325
8443
 
8326
8444
  exports.LightningElement = LightningElement;
8327
8445
  exports.__unstable__ProfilerControl = profilerControl;
@@ -47,7 +47,7 @@ var assert = /*#__PURE__*/Object.freeze({
47
47
  */
48
48
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
49
49
  const { isArray: isArray$1 } = Array;
50
- 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;
50
+ 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;
51
51
  const { fromCharCode: StringFromCharCode } = String;
52
52
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
53
53
  function isUndefined$1(obj) {
@@ -436,9 +436,9 @@ function htmlEscape(str, attrMode = false) {
436
436
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
437
437
  */
438
438
  // Increment whenever the LWC template compiler changes
439
- const LWC_VERSION = "2.26.2";
439
+ const LWC_VERSION = "2.28.0";
440
440
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
441
- /** version: 2.26.2 */
441
+ /** version: 2.28.0 */
442
442
 
443
443
  /*
444
444
  * Copyright (c) 2020, salesforce.com, inc.
@@ -550,7 +550,7 @@ function setFeatureFlagForTest(name, value) {
550
550
  setFeatureFlag(name, value);
551
551
  }
552
552
  }
553
- /** version: 2.26.2 */
553
+ /** version: 2.28.0 */
554
554
 
555
555
  /* proxy-compat-disable */
556
556
 
@@ -3441,6 +3441,9 @@ function isVBaseElement(vnode) {
3441
3441
  function isSameVnode(vnode1, vnode2) {
3442
3442
  return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
3443
3443
  }
3444
+ function isVScopedSlotFragment(vnode) {
3445
+ return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3446
+ }
3444
3447
 
3445
3448
  /*
3446
3449
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4258,13 +4261,24 @@ function allocateChildren(vnode, vm) {
4258
4261
  shadowMode
4259
4262
  } = vm;
4260
4263
 
4264
+ if (process.env.NODE_ENV !== 'production') {
4265
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4266
+ // component is a light DOM component. This is mainly to validate light dom parent running
4267
+ // in native shadow mode.
4268
+ if (renderMode !== 0
4269
+ /* RenderMode.Light */
4270
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4271
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4272
+ }
4273
+ }
4274
+
4261
4275
  if (shadowMode === 1
4262
4276
  /* ShadowMode.Synthetic */
4263
4277
  || renderMode === 0
4264
4278
  /* RenderMode.Light */
4265
4279
  ) {
4266
4280
  // slow path
4267
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4281
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4268
4282
 
4269
4283
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4270
4284
 
@@ -4300,13 +4314,19 @@ function createViewModelHook(elm, vnode, renderer) {
4300
4314
  return vm;
4301
4315
  }
4302
4316
 
4303
- function allocateInSlot(vm, children) {
4304
- var _a;
4317
+ function allocateInSlot(vm, children, owner) {
4318
+ var _a, _b;
4305
4319
 
4306
4320
  const {
4307
- cmpSlots: oldSlots
4321
+ cmpSlots: {
4322
+ slotAssignments: oldSlotsMapping
4323
+ }
4308
4324
  } = vm;
4309
- const cmpSlots = vm.cmpSlots = create(null);
4325
+ const cmpSlotsMapping = create(null);
4326
+ vm.cmpSlots = {
4327
+ owner,
4328
+ slotAssignments: cmpSlotsMapping
4329
+ };
4310
4330
 
4311
4331
  for (let i = 0, len = children.length; i < len; i += 1) {
4312
4332
  const vnode = children[i];
@@ -4318,19 +4338,21 @@ function allocateInSlot(vm, children) {
4318
4338
  let slotName = '';
4319
4339
 
4320
4340
  if (isVBaseElement(vnode)) {
4321
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4341
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4342
+ } else if (isVScopedSlotFragment(vnode)) {
4343
+ slotName = vnode.slotName;
4322
4344
  }
4323
4345
 
4324
- const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4346
+ const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4325
4347
  ArrayPush$1.call(vnodes, vnode);
4326
4348
  }
4327
4349
 
4328
4350
  if (isFalse(vm.isDirty)) {
4329
4351
  // We need to determine if the old allocation is really different from the new one
4330
4352
  // and mark the vm as dirty
4331
- const oldKeys = keys(oldSlots);
4353
+ const oldKeys = keys(oldSlotsMapping);
4332
4354
 
4333
- if (oldKeys.length !== keys(cmpSlots).length) {
4355
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4334
4356
  markComponentAsDirty(vm);
4335
4357
  return;
4336
4358
  }
@@ -4338,15 +4360,15 @@ function allocateInSlot(vm, children) {
4338
4360
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4339
4361
  const key = oldKeys[i];
4340
4362
 
4341
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4363
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4342
4364
  markComponentAsDirty(vm);
4343
4365
  return;
4344
4366
  }
4345
4367
 
4346
- const oldVNodes = oldSlots[key];
4347
- const vnodes = cmpSlots[key];
4368
+ const oldVNodes = oldSlotsMapping[key];
4369
+ const vnodes = cmpSlotsMapping[key];
4348
4370
 
4349
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4371
+ for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4350
4372
  if (oldVNodes[j] !== vnodes[j]) {
4351
4373
  markComponentAsDirty(vm);
4352
4374
  return;
@@ -4546,6 +4568,18 @@ const SymbolIterator = Symbol.iterator;
4546
4568
  function addVNodeToChildLWC(vnode) {
4547
4569
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4548
4570
  }
4571
+ // [s]coped [s]lot [f]actory
4572
+ function ssf(slotName, factory) {
4573
+ return {
4574
+ type: 6 /* VNodeType.ScopedSlotFragment */,
4575
+ factory,
4576
+ owner: getVMBeingRendered(),
4577
+ elm: undefined,
4578
+ sel: undefined,
4579
+ key: undefined,
4580
+ slotName,
4581
+ };
4582
+ }
4549
4583
  // [st]atic node
4550
4584
  function st(fragment, key) {
4551
4585
  return {
@@ -4629,9 +4663,46 @@ function s(slotName, data, children, slotset) {
4629
4663
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
4630
4664
  }
4631
4665
  if (!isUndefined$1(slotset) &&
4632
- !isUndefined$1(slotset[slotName]) &&
4633
- slotset[slotName].length !== 0) {
4634
- children = slotset[slotName];
4666
+ !isUndefined$1(slotset.slotAssignments) &&
4667
+ !isUndefined$1(slotset.slotAssignments[slotName]) &&
4668
+ slotset.slotAssignments[slotName].length !== 0) {
4669
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4670
+ if (vnode) {
4671
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4672
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4673
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4674
+ // Check if slot types of parent and child are matching
4675
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4676
+ if (process.env.NODE_ENV !== 'production') {
4677
+ 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);
4678
+ }
4679
+ // Ignore slot content from parent
4680
+ return accumulator;
4681
+ }
4682
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4683
+ if (assignedNodeIsScopedSlot) {
4684
+ const vmBeingRenderedInception = getVMBeingRendered();
4685
+ let scopedSlotChildren = [];
4686
+ // Evaluate in the scope of the slot content's owner
4687
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4688
+ // undefined is for root components, but root components cannot accept slotted content
4689
+ setVMBeingRendered(slotset.owner);
4690
+ try {
4691
+ scopedSlotChildren = vnode.factory(data.slotData);
4692
+ }
4693
+ finally {
4694
+ setVMBeingRendered(vmBeingRenderedInception);
4695
+ }
4696
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4697
+ }
4698
+ else {
4699
+ // If the slot content is standard type, the content is static, no additional
4700
+ // processing needed on the vnode
4701
+ return ArrayConcat$1.call(accumulator, vnode);
4702
+ }
4703
+ }
4704
+ return accumulator;
4705
+ }, []);
4635
4706
  }
4636
4707
  const vmBeingRendered = getVMBeingRendered();
4637
4708
  const { renderMode, shadowMode } = vmBeingRendered;
@@ -4951,6 +5022,7 @@ const api = freeze({
4951
5022
  gid,
4952
5023
  fid,
4953
5024
  shc,
5025
+ ssf,
4954
5026
  });
4955
5027
 
4956
5028
  /*
@@ -5053,9 +5125,9 @@ function validateSlots(vm, html) {
5053
5125
  }
5054
5126
  const { cmpSlots } = vm;
5055
5127
  const { slots = EmptyArray } = html;
5056
- for (const slotName in cmpSlots) {
5128
+ for (const slotName in cmpSlots.slotAssignments) {
5057
5129
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
5058
- 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}.`);
5130
+ 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}.`);
5059
5131
  if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
5060
5132
  // TODO [#1297]: this should never really happen because the compiler should always validate
5061
5133
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
@@ -5541,7 +5613,9 @@ function createVM(elm, ctor, renderer, options) {
5541
5613
  velements: EmptyArray,
5542
5614
  cmpProps: create(null),
5543
5615
  cmpFields: create(null),
5544
- cmpSlots: create(null),
5616
+ cmpSlots: {
5617
+ slotAssignments: create(null)
5618
+ },
5545
5619
  oar: create(null),
5546
5620
  cmpTemplate: null,
5547
5621
  hydrated: Boolean(hydrated),
@@ -6413,7 +6487,7 @@ function freezeTemplate(tmpl) {
6413
6487
  });
6414
6488
  }
6415
6489
  }
6416
- /* version: 2.26.2 */
6490
+ /* version: 2.28.0 */
6417
6491
 
6418
6492
  /*
6419
6493
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6878,7 +6952,7 @@ function renderComponent(tagName, Ctor, props = {}) {
6878
6952
  */
6879
6953
  freeze(LightningElement);
6880
6954
  seal(LightningElement.prototype);
6881
- /* version: 2.26.2 */
6955
+ /* version: 2.28.0 */
6882
6956
 
6883
6957
  exports.LightningElement = LightningElement;
6884
6958
  exports.api = api$1;