@lwc/engine-core 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.
@@ -3229,6 +3229,9 @@ function isSameVnode(vnode1, vnode2) {
3229
3229
  function isVCustomElement(vnode) {
3230
3230
  return vnode.type === 3 /* VNodeType.CustomElement */;
3231
3231
  }
3232
+ function isVScopedSlotFragment(vnode) {
3233
+ return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3234
+ }
3232
3235
 
3233
3236
  /*
3234
3237
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4066,13 +4069,24 @@ function allocateChildren(vnode, vm) {
4066
4069
  shadowMode
4067
4070
  } = vm;
4068
4071
 
4072
+ if (process.env.NODE_ENV !== 'production') {
4073
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4074
+ // component is a light DOM component. This is mainly to validate light dom parent running
4075
+ // in native shadow mode.
4076
+ if (renderMode !== 0
4077
+ /* RenderMode.Light */
4078
+ && shared.ArraySome.call(children, child => !shared.isNull(child) && isVScopedSlotFragment(child))) {
4079
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4080
+ }
4081
+ }
4082
+
4069
4083
  if (shadowMode === 1
4070
4084
  /* ShadowMode.Synthetic */
4071
4085
  || renderMode === 0
4072
4086
  /* RenderMode.Light */
4073
4087
  ) {
4074
4088
  // slow path
4075
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4089
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4076
4090
 
4077
4091
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4078
4092
 
@@ -4108,13 +4122,19 @@ function createViewModelHook(elm, vnode, renderer) {
4108
4122
  return vm;
4109
4123
  }
4110
4124
 
4111
- function allocateInSlot(vm, children) {
4112
- var _a;
4125
+ function allocateInSlot(vm, children, owner) {
4126
+ var _a, _b;
4113
4127
 
4114
4128
  const {
4115
- cmpSlots: oldSlots
4129
+ cmpSlots: {
4130
+ slotAssignments: oldSlotsMapping
4131
+ }
4116
4132
  } = vm;
4117
- const cmpSlots = vm.cmpSlots = shared.create(null);
4133
+ const cmpSlotsMapping = shared.create(null);
4134
+ vm.cmpSlots = {
4135
+ owner,
4136
+ slotAssignments: cmpSlotsMapping
4137
+ };
4118
4138
 
4119
4139
  for (let i = 0, len = children.length; i < len; i += 1) {
4120
4140
  const vnode = children[i];
@@ -4126,19 +4146,21 @@ function allocateInSlot(vm, children) {
4126
4146
  let slotName = '';
4127
4147
 
4128
4148
  if (isVBaseElement(vnode)) {
4129
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4149
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4150
+ } else if (isVScopedSlotFragment(vnode)) {
4151
+ slotName = vnode.slotName;
4130
4152
  }
4131
4153
 
4132
- const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4154
+ const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4133
4155
  shared.ArrayPush.call(vnodes, vnode);
4134
4156
  }
4135
4157
 
4136
4158
  if (shared.isFalse(vm.isDirty)) {
4137
4159
  // We need to determine if the old allocation is really different from the new one
4138
4160
  // and mark the vm as dirty
4139
- const oldKeys = shared.keys(oldSlots);
4161
+ const oldKeys = shared.keys(oldSlotsMapping);
4140
4162
 
4141
- if (oldKeys.length !== shared.keys(cmpSlots).length) {
4163
+ if (oldKeys.length !== shared.keys(cmpSlotsMapping).length) {
4142
4164
  markComponentAsDirty(vm);
4143
4165
  return;
4144
4166
  }
@@ -4146,15 +4168,15 @@ function allocateInSlot(vm, children) {
4146
4168
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4147
4169
  const key = oldKeys[i];
4148
4170
 
4149
- if (shared.isUndefined(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4171
+ if (shared.isUndefined(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4150
4172
  markComponentAsDirty(vm);
4151
4173
  return;
4152
4174
  }
4153
4175
 
4154
- const oldVNodes = oldSlots[key];
4155
- const vnodes = cmpSlots[key];
4176
+ const oldVNodes = oldSlotsMapping[key];
4177
+ const vnodes = cmpSlotsMapping[key];
4156
4178
 
4157
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4179
+ for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4158
4180
  if (oldVNodes[j] !== vnodes[j]) {
4159
4181
  markComponentAsDirty(vm);
4160
4182
  return;
@@ -4354,6 +4376,18 @@ const SymbolIterator = Symbol.iterator;
4354
4376
  function addVNodeToChildLWC(vnode) {
4355
4377
  shared.ArrayPush.call(getVMBeingRendered().velements, vnode);
4356
4378
  }
4379
+ // [s]coped [s]lot [f]actory
4380
+ function ssf(slotName, factory) {
4381
+ return {
4382
+ type: 6 /* VNodeType.ScopedSlotFragment */,
4383
+ factory,
4384
+ owner: getVMBeingRendered(),
4385
+ elm: undefined,
4386
+ sel: undefined,
4387
+ key: undefined,
4388
+ slotName,
4389
+ };
4390
+ }
4357
4391
  // [st]atic node
4358
4392
  function st(fragment, key) {
4359
4393
  return {
@@ -4437,9 +4471,46 @@ function s(slotName, data, children, slotset) {
4437
4471
  shared.assert.isTrue(shared.isArray(children), `h() 3rd argument children must be an array.`);
4438
4472
  }
4439
4473
  if (!shared.isUndefined(slotset) &&
4440
- !shared.isUndefined(slotset[slotName]) &&
4441
- slotset[slotName].length !== 0) {
4442
- children = slotset[slotName];
4474
+ !shared.isUndefined(slotset.slotAssignments) &&
4475
+ !shared.isUndefined(slotset.slotAssignments[slotName]) &&
4476
+ slotset.slotAssignments[slotName].length !== 0) {
4477
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4478
+ if (vnode) {
4479
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4480
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4481
+ const isScopedSlotElement = !shared.isUndefined(data.slotData);
4482
+ // Check if slot types of parent and child are matching
4483
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4484
+ if (process.env.NODE_ENV !== 'production') {
4485
+ 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);
4486
+ }
4487
+ // Ignore slot content from parent
4488
+ return accumulator;
4489
+ }
4490
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4491
+ if (assignedNodeIsScopedSlot) {
4492
+ const vmBeingRenderedInception = getVMBeingRendered();
4493
+ let scopedSlotChildren = [];
4494
+ // Evaluate in the scope of the slot content's owner
4495
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4496
+ // undefined is for root components, but root components cannot accept slotted content
4497
+ setVMBeingRendered(slotset.owner);
4498
+ try {
4499
+ scopedSlotChildren = vnode.factory(data.slotData);
4500
+ }
4501
+ finally {
4502
+ setVMBeingRendered(vmBeingRenderedInception);
4503
+ }
4504
+ return shared.ArrayConcat.call(accumulator, scopedSlotChildren);
4505
+ }
4506
+ else {
4507
+ // If the slot content is standard type, the content is static, no additional
4508
+ // processing needed on the vnode
4509
+ return shared.ArrayConcat.call(accumulator, vnode);
4510
+ }
4511
+ }
4512
+ return accumulator;
4513
+ }, []);
4443
4514
  }
4444
4515
  const vmBeingRendered = getVMBeingRendered();
4445
4516
  const { renderMode, shadowMode } = vmBeingRendered;
@@ -4759,6 +4830,7 @@ const api = shared.freeze({
4759
4830
  gid,
4760
4831
  fid,
4761
4832
  shc,
4833
+ ssf,
4762
4834
  });
4763
4835
 
4764
4836
  /*
@@ -4895,9 +4967,9 @@ function validateSlots(vm, html) {
4895
4967
  }
4896
4968
  const { cmpSlots } = vm;
4897
4969
  const { slots = EmptyArray } = html;
4898
- for (const slotName in cmpSlots) {
4970
+ for (const slotName in cmpSlots.slotAssignments) {
4899
4971
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
4900
- shared.assert.isTrue(shared.isArray(cmpSlots[slotName]), `Slots can only be set to an array, instead received ${shared.toString(cmpSlots[slotName])} for slot "${slotName}" in ${vm}.`);
4972
+ shared.assert.isTrue(shared.isArray(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${shared.toString(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
4901
4973
  if (slotName !== '' && shared.ArrayIndexOf.call(slots, slotName) === -1) {
4902
4974
  // TODO [#1297]: this should never really happen because the compiler should always validate
4903
4975
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
@@ -5394,7 +5466,9 @@ function createVM(elm, ctor, renderer, options) {
5394
5466
  velements: EmptyArray,
5395
5467
  cmpProps: shared.create(null),
5396
5468
  cmpFields: shared.create(null),
5397
- cmpSlots: shared.create(null),
5469
+ cmpSlots: {
5470
+ slotAssignments: shared.create(null)
5471
+ },
5398
5472
  oar: shared.create(null),
5399
5473
  cmpTemplate: null,
5400
5474
  hydrated: Boolean(hydrated),
@@ -6845,4 +6919,4 @@ exports.swapTemplate = swapTemplate;
6845
6919
  exports.track = track;
6846
6920
  exports.unwrap = unwrap;
6847
6921
  exports.wire = wire;
6848
- /* version: 2.26.2 */
6922
+ /* version: 2.28.0 */
@@ -1,7 +1,7 @@
1
1
  /* proxy-compat-disable */
2
2
  import { lwcRuntimeFlags } from '@lwc/features';
3
3
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
4
- import { seal, create, isUndefined as isUndefined$1, isFunction as isFunction$1, ArrayPush as ArrayPush$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, freeze, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayFilter, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
4
+ import { seal, create, isUndefined as isUndefined$1, isFunction as isFunction$1, ArrayPush as ArrayPush$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, freeze, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayConcat as ArrayConcat$1, isNumber, StringReplace, noop, ArrayUnshift, ArrayFilter, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
5
5
 
6
6
  /*
7
7
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3226,6 +3226,9 @@ function isSameVnode(vnode1, vnode2) {
3226
3226
  function isVCustomElement(vnode) {
3227
3227
  return vnode.type === 3 /* VNodeType.CustomElement */;
3228
3228
  }
3229
+ function isVScopedSlotFragment(vnode) {
3230
+ return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
3231
+ }
3229
3232
 
3230
3233
  /*
3231
3234
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4063,13 +4066,24 @@ function allocateChildren(vnode, vm) {
4063
4066
  shadowMode
4064
4067
  } = vm;
4065
4068
 
4069
+ if (process.env.NODE_ENV !== 'production') {
4070
+ // If any of the children being allocated is a scoped slot fragment, make sure the receiving
4071
+ // component is a light DOM component. This is mainly to validate light dom parent running
4072
+ // in native shadow mode.
4073
+ if (renderMode !== 0
4074
+ /* RenderMode.Light */
4075
+ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
4076
+ logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
4077
+ }
4078
+ }
4079
+
4066
4080
  if (shadowMode === 1
4067
4081
  /* ShadowMode.Synthetic */
4068
4082
  || renderMode === 0
4069
4083
  /* RenderMode.Light */
4070
4084
  ) {
4071
4085
  // slow path
4072
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4086
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
4073
4087
 
4074
4088
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4075
4089
 
@@ -4105,13 +4119,19 @@ function createViewModelHook(elm, vnode, renderer) {
4105
4119
  return vm;
4106
4120
  }
4107
4121
 
4108
- function allocateInSlot(vm, children) {
4109
- var _a;
4122
+ function allocateInSlot(vm, children, owner) {
4123
+ var _a, _b;
4110
4124
 
4111
4125
  const {
4112
- cmpSlots: oldSlots
4126
+ cmpSlots: {
4127
+ slotAssignments: oldSlotsMapping
4128
+ }
4113
4129
  } = vm;
4114
- const cmpSlots = vm.cmpSlots = create(null);
4130
+ const cmpSlotsMapping = create(null);
4131
+ vm.cmpSlots = {
4132
+ owner,
4133
+ slotAssignments: cmpSlotsMapping
4134
+ };
4115
4135
 
4116
4136
  for (let i = 0, len = children.length; i < len; i += 1) {
4117
4137
  const vnode = children[i];
@@ -4123,19 +4143,21 @@ function allocateInSlot(vm, children) {
4123
4143
  let slotName = '';
4124
4144
 
4125
4145
  if (isVBaseElement(vnode)) {
4126
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4146
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
4147
+ } else if (isVScopedSlotFragment(vnode)) {
4148
+ slotName = vnode.slotName;
4127
4149
  }
4128
4150
 
4129
- const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4151
+ const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4130
4152
  ArrayPush$1.call(vnodes, vnode);
4131
4153
  }
4132
4154
 
4133
4155
  if (isFalse(vm.isDirty)) {
4134
4156
  // We need to determine if the old allocation is really different from the new one
4135
4157
  // and mark the vm as dirty
4136
- const oldKeys = keys(oldSlots);
4158
+ const oldKeys = keys(oldSlotsMapping);
4137
4159
 
4138
- if (oldKeys.length !== keys(cmpSlots).length) {
4160
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
4139
4161
  markComponentAsDirty(vm);
4140
4162
  return;
4141
4163
  }
@@ -4143,15 +4165,15 @@ function allocateInSlot(vm, children) {
4143
4165
  for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4144
4166
  const key = oldKeys[i];
4145
4167
 
4146
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4168
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
4147
4169
  markComponentAsDirty(vm);
4148
4170
  return;
4149
4171
  }
4150
4172
 
4151
- const oldVNodes = oldSlots[key];
4152
- const vnodes = cmpSlots[key];
4173
+ const oldVNodes = oldSlotsMapping[key];
4174
+ const vnodes = cmpSlotsMapping[key];
4153
4175
 
4154
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4176
+ for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
4155
4177
  if (oldVNodes[j] !== vnodes[j]) {
4156
4178
  markComponentAsDirty(vm);
4157
4179
  return;
@@ -4351,6 +4373,18 @@ const SymbolIterator = Symbol.iterator;
4351
4373
  function addVNodeToChildLWC(vnode) {
4352
4374
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4353
4375
  }
4376
+ // [s]coped [s]lot [f]actory
4377
+ function ssf(slotName, factory) {
4378
+ return {
4379
+ type: 6 /* VNodeType.ScopedSlotFragment */,
4380
+ factory,
4381
+ owner: getVMBeingRendered(),
4382
+ elm: undefined,
4383
+ sel: undefined,
4384
+ key: undefined,
4385
+ slotName,
4386
+ };
4387
+ }
4354
4388
  // [st]atic node
4355
4389
  function st(fragment, key) {
4356
4390
  return {
@@ -4434,9 +4468,46 @@ function s(slotName, data, children, slotset) {
4434
4468
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
4435
4469
  }
4436
4470
  if (!isUndefined$1(slotset) &&
4437
- !isUndefined$1(slotset[slotName]) &&
4438
- slotset[slotName].length !== 0) {
4439
- children = slotset[slotName];
4471
+ !isUndefined$1(slotset.slotAssignments) &&
4472
+ !isUndefined$1(slotset.slotAssignments[slotName]) &&
4473
+ slotset.slotAssignments[slotName].length !== 0) {
4474
+ children = slotset.slotAssignments[slotName].reduce((accumulator, vnode) => {
4475
+ if (vnode) {
4476
+ const assignedNodeIsScopedSlot = isVScopedSlotFragment(vnode);
4477
+ // The only sniff test for a scoped <slot> element is the presence of `slotData`
4478
+ const isScopedSlotElement = !isUndefined$1(data.slotData);
4479
+ // Check if slot types of parent and child are matching
4480
+ if (assignedNodeIsScopedSlot !== isScopedSlotElement) {
4481
+ if (process.env.NODE_ENV !== 'production') {
4482
+ 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);
4483
+ }
4484
+ // Ignore slot content from parent
4485
+ return accumulator;
4486
+ }
4487
+ // If the passed slot content is factory, evaluate it and add the produced vnodes
4488
+ if (assignedNodeIsScopedSlot) {
4489
+ const vmBeingRenderedInception = getVMBeingRendered();
4490
+ let scopedSlotChildren = [];
4491
+ // Evaluate in the scope of the slot content's owner
4492
+ // if a slotset is provided, there will always be an owner. The only case where owner is
4493
+ // undefined is for root components, but root components cannot accept slotted content
4494
+ setVMBeingRendered(slotset.owner);
4495
+ try {
4496
+ scopedSlotChildren = vnode.factory(data.slotData);
4497
+ }
4498
+ finally {
4499
+ setVMBeingRendered(vmBeingRenderedInception);
4500
+ }
4501
+ return ArrayConcat$1.call(accumulator, scopedSlotChildren);
4502
+ }
4503
+ else {
4504
+ // If the slot content is standard type, the content is static, no additional
4505
+ // processing needed on the vnode
4506
+ return ArrayConcat$1.call(accumulator, vnode);
4507
+ }
4508
+ }
4509
+ return accumulator;
4510
+ }, []);
4440
4511
  }
4441
4512
  const vmBeingRendered = getVMBeingRendered();
4442
4513
  const { renderMode, shadowMode } = vmBeingRendered;
@@ -4756,6 +4827,7 @@ const api = freeze({
4756
4827
  gid,
4757
4828
  fid,
4758
4829
  shc,
4830
+ ssf,
4759
4831
  });
4760
4832
 
4761
4833
  /*
@@ -4892,9 +4964,9 @@ function validateSlots(vm, html) {
4892
4964
  }
4893
4965
  const { cmpSlots } = vm;
4894
4966
  const { slots = EmptyArray } = html;
4895
- for (const slotName in cmpSlots) {
4967
+ for (const slotName in cmpSlots.slotAssignments) {
4896
4968
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
4897
- 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}.`);
4969
+ 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}.`);
4898
4970
  if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
4899
4971
  // TODO [#1297]: this should never really happen because the compiler should always validate
4900
4972
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
@@ -5391,7 +5463,9 @@ function createVM(elm, ctor, renderer, options) {
5391
5463
  velements: EmptyArray,
5392
5464
  cmpProps: create(null),
5393
5465
  cmpFields: create(null),
5394
- cmpSlots: create(null),
5466
+ cmpSlots: {
5467
+ slotAssignments: create(null)
5468
+ },
5395
5469
  oar: create(null),
5396
5470
  cmpTemplate: null,
5397
5471
  hydrated: Boolean(hydrated),
@@ -6806,4 +6880,4 @@ function getComponentConstructor(elm) {
6806
6880
  }
6807
6881
 
6808
6882
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6809
- /* version: 2.26.2 */
6883
+ /* version: 2.28.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.26.2",
3
+ "version": "2.28.0",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.26.2",
28
- "@lwc/shared": "2.26.2"
27
+ "@lwc/features": "2.28.0",
28
+ "@lwc/shared": "2.28.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "observable-membrane": "2.0.0"
@@ -43,4 +43,4 @@
43
43
  }
44
44
  }
45
45
  }
46
- }
46
+ }
@@ -1,6 +1,7 @@
1
1
  import { SlotSet } from './vm';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
- import { VNode, VNodes, VElement, VText, VCustomElement, VComment, VElementData, VStatic, Key, VFragment } from './vnodes';
3
+ import { VNode, VNodes, VElement, VText, VCustomElement, VComment, VElementData, VStatic, Key, VFragment, VScopedSlotFragment } from './vnodes';
4
+ declare function ssf(slotName: string, factory: (value: any) => VNodes): VScopedSlotFragment;
4
5
  declare function st(fragment: Element, key: Key): VStatic;
5
6
  declare function fr(key: Key, children: VNodes, stable: 0 | 1): VFragment;
6
7
  declare function h(sel: string, data: VElementData, children?: VNodes): VElement;
@@ -47,6 +48,7 @@ declare const api: Readonly<{
47
48
  gid: typeof gid;
48
49
  fid: typeof fid;
49
50
  shc: typeof shc;
51
+ ssf: typeof ssf;
50
52
  }>;
51
53
  export default api;
52
54
  export declare type RenderAPI = typeof api;
@@ -10,7 +10,10 @@ export interface TemplateCache {
10
10
  [key: string]: any;
11
11
  }
12
12
  export interface SlotSet {
13
- [key: string]: VNodes;
13
+ slotAssignments: {
14
+ [key: string]: VNodes;
15
+ };
16
+ owner?: VM;
14
17
  }
15
18
  export declare const enum VMState {
16
19
  created = 0,
@@ -91,7 +94,8 @@ export interface VM<N = HostNode, E = HostElement> {
91
94
  cmpProps: {
92
95
  [name: string]: any;
93
96
  };
94
- /** The mapping between the slot names and the slotted VNodes. */
97
+ /** Contains information about the mapping between the slot names and the slotted VNodes, and
98
+ * the owner of the slot content. */
95
99
  cmpSlots: SlotSet;
96
100
  /** The component internal reactive properties. */
97
101
  cmpFields: {
@@ -7,9 +7,10 @@ export declare const enum VNodeType {
7
7
  Element = 2,
8
8
  CustomElement = 3,
9
9
  Static = 4,
10
- Fragment = 5
10
+ Fragment = 5,
11
+ ScopedSlotFragment = 6
11
12
  }
12
- export declare type VNode = VText | VComment | VElement | VCustomElement | VStatic | VFragment;
13
+ export declare type VNode = VText | VComment | VElement | VCustomElement | VStatic | VFragment | VScopedSlotFragment;
13
14
  export declare type VParentElement = VElement | VCustomElement | VFragment;
14
15
  export declare type VNodes = Readonly<Array<VNode | null>>;
15
16
  export interface BaseVParent {
@@ -22,6 +23,11 @@ export interface BaseVNode {
22
23
  key: Key | undefined;
23
24
  owner: VM;
24
25
  }
26
+ export interface VScopedSlotFragment extends BaseVNode {
27
+ factory: (value: any) => VNodes;
28
+ type: VNodeType.ScopedSlotFragment;
29
+ slotName: string;
30
+ }
25
31
  export interface VStatic extends BaseVNode {
26
32
  type: VNodeType.Static;
27
33
  sel: undefined;
@@ -77,7 +83,9 @@ export interface VNodeData {
77
83
  export interface VElementData extends VNodeData {
78
84
  readonly key: Key;
79
85
  readonly ref?: string;
86
+ readonly slotData?: any;
80
87
  }
81
88
  export declare function isVBaseElement(vnode: VNode): vnode is VElement | VCustomElement;
82
89
  export declare function isSameVnode(vnode1: VNode, vnode2: VNode): boolean;
83
90
  export declare function isVCustomElement(vnode: VBaseElement): vnode is VCustomElement;
91
+ export declare function isVScopedSlotFragment(vnode: VNode): vnode is VScopedSlotFragment;
@@ -1,11 +0,0 @@
1
- /**
2
- @license
3
- Copyright (c) 2015 Simon Friis Vindum.
4
- This code may only be used under the MIT License found at
5
- https://github.com/snabbdom/snabbdom/blob/master/LICENSE
6
- Code distributed by Snabbdom as part of the Snabbdom project at
7
- https://github.com/snabbdom/snabbdom/
8
- */
9
- import { VNodes } from './types';
10
- export declare function updateDynamicChildren(parentElm: Node, oldCh: VNodes, newCh: VNodes): void;
11
- export declare function updateStaticChildren(parentElm: Node, oldCh: VNodes, newCh: VNodes): void;
@@ -1,70 +0,0 @@
1
- /**
2
- @license
3
- Copyright (c) 2015 Simon Friis Vindum.
4
- This code may only be used under the MIT License found at
5
- https://github.com/snabbdom/snabbdom/blob/master/LICENSE
6
- Code distributed by Snabbdom as part of the Snabbdom project at
7
- https://github.com/snabbdom/snabbdom/
8
- */
9
- import { VM } from '../../framework/vm';
10
- export declare type Key = string | number;
11
- export declare type VNodes = Array<VNode | null>;
12
- export interface VNode {
13
- sel: string | undefined;
14
- data: VNodeData;
15
- children: VNodes | undefined;
16
- elm: Node | undefined;
17
- parentElm?: Element;
18
- text: string | undefined;
19
- key: Key | undefined;
20
- hook: Hooks<any>;
21
- owner: VM;
22
- }
23
- export interface VElement extends VNode {
24
- sel: string;
25
- data: VElementData;
26
- children: VNodes;
27
- elm: Element | undefined;
28
- text: undefined;
29
- key: Key;
30
- }
31
- export interface VCustomElement extends VElement {
32
- mode: 'closed' | 'open';
33
- ctor: any;
34
- aChildren?: VNodes;
35
- }
36
- export interface VText extends VNode {
37
- sel: undefined;
38
- children: undefined;
39
- elm: Node | undefined;
40
- text: string;
41
- key: undefined;
42
- }
43
- export interface VComment extends VNode {
44
- sel: undefined;
45
- children: undefined;
46
- text: string;
47
- key: undefined;
48
- }
49
- export interface VNodeData {
50
- props?: Record<string, any>;
51
- attrs?: Record<string, string | number | boolean>;
52
- className?: string;
53
- style?: string;
54
- classMap?: Record<string, boolean>;
55
- styleDecls?: Array<[string, string, boolean]>;
56
- context?: Record<string, Record<string, any>>;
57
- on?: Record<string, Function>;
58
- svg?: boolean;
59
- }
60
- export interface VElementData extends VNodeData {
61
- key: Key;
62
- }
63
- export interface Hooks<N extends VNode> {
64
- create: (vNode: N) => void;
65
- insert: (vNode: N, parentNode: Node, referenceNode: Node | null) => void;
66
- move: (vNode: N, parentNode: Node, referenceNode: Node | null) => void;
67
- update: (oldVNode: N, vNode: N) => void;
68
- remove: (vNode: N, parentNode: Node) => void;
69
- hydrate: (vNode: N, node: Node) => void;
70
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3
- * libraries to sanitize HTML content. This hook process the content passed via the template to
4
- * lwc:inner-html directive.
5
- * It is meant to be overridden with setSanitizeHtmlContentHook
6
- */
7
- export declare let sanitizeHtmlContentHook: SanitizeHtmlContentHook;
8
- export declare type SanitizeHtmlContentHook = (content: unknown) => string;
9
- /**
10
- * Sets the sanitizeHtmlContentHook.
11
- *
12
- * @param newHookImpl
13
- * @returns oldHookImplementation.
14
- */
15
- export declare function setSanitizeHtmlContentHook(newHookImpl: SanitizeHtmlContentHook): SanitizeHtmlContentHook;
@@ -1,9 +0,0 @@
1
- import { VM } from './vm';
2
- import { VNodes, VCustomElement, VElement, VText, VComment, Hooks } from './vnodes';
3
- export declare const TextHook: Hooks<VText>;
4
- export declare const CommentHook: Hooks<VComment>;
5
- export declare const ElementHook: Hooks<VElement>;
6
- export declare const CustomElementHook: Hooks<VCustomElement>;
7
- export declare function patchChildren(parent: ParentNode, oldCh: VNodes, newCh: VNodes): void;
8
- export declare function hydrateChildrenHook(elmChildren: NodeListOf<ChildNode>, children: VNodes, vm?: VM): void;
9
- export declare function markAsDynamicChildren(children: VNodes): void;
@@ -1,2 +0,0 @@
1
- import { VM } from '../vm';
2
- export declare function getScopeTokenClass(owner: VM): string | null;
@@ -1,10 +0,0 @@
1
- import { VM } from './vm';
2
- export declare type MeasurementPhase = 'constructor' | 'render' | 'patch' | 'connectedCallback' | 'disconnectedCallback' | 'renderedCallback' | 'errorCallback';
3
- export declare enum GlobalMeasurementPhase {
4
- REHYDRATE = "lwc-rehydrate",
5
- HYDRATE = "lwc-hydrate"
6
- }
7
- export declare const startMeasure: (phase: MeasurementPhase, vm: VM) => void;
8
- export declare const endMeasure: (phase: MeasurementPhase, vm: VM) => void;
9
- export declare const startGlobalMeasure: (phase: GlobalMeasurementPhase, vm?: VM<any, any> | undefined) => void;
10
- export declare const endGlobalMeasure: (phase: GlobalMeasurementPhase, vm?: VM<any, any> | undefined) => void;
@@ -1,7 +0,0 @@
1
- import type { RendererAPI } from './renderer';
2
- declare type UpgradeCallback = (elm: HTMLElement) => void;
3
- interface UpgradableCustomElementConstructor extends CustomElementConstructor {
4
- new (upgradeCallback?: UpgradeCallback): HTMLElement;
5
- }
6
- export declare function getUpgradableConstructor(tagName: string, renderer: RendererAPI): CustomElementConstructor | UpgradableCustomElementConstructor;
7
- export {};
@@ -1,119 +0,0 @@
1
- export declare type HostNode = any;
2
- export declare type HostElement = any;
3
- declare type N = HostNode;
4
- declare type E = HostElement;
5
- export declare let ssr: boolean;
6
- export declare function setSsr(ssrImpl: boolean): void;
7
- export declare let isNativeShadowDefined: boolean;
8
- export declare function setIsNativeShadowDefined(isNativeShadowDefinedImpl: boolean): void;
9
- export declare let isSyntheticShadowDefined: boolean;
10
- export declare function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl: boolean): void;
11
- declare type HTMLElementType = typeof HTMLElement;
12
- declare let HTMLElementExported: HTMLElementType;
13
- export { HTMLElementExported as HTMLElement };
14
- export declare function setHTMLElement(HTMLElementImpl: HTMLElementType): void;
15
- declare type isHydratingFunc = () => boolean;
16
- export declare let isHydrating: isHydratingFunc;
17
- export declare function setIsHydrating(isHydratingImpl: isHydratingFunc): void;
18
- declare type insertFunc = (node: N, parent: E, anchor: N | null) => void;
19
- export declare let insert: insertFunc;
20
- export declare function setInsert(insertImpl: insertFunc): void;
21
- declare type removeFunc = (node: N, parent: E) => void;
22
- export declare let remove: removeFunc;
23
- export declare function setRemove(removeImpl: removeFunc): void;
24
- declare type createElementFunc = (tagName: string, namespace?: string) => E;
25
- export declare let createElement: createElementFunc;
26
- export declare function setCreateElement(createElementImpl: createElementFunc): void;
27
- declare type createTextFunc = (content: string) => N;
28
- export declare let createText: createTextFunc;
29
- export declare function setCreateText(createTextImpl: createTextFunc): void;
30
- declare type createCommentFunc = (content: string) => N;
31
- export declare let createComment: createCommentFunc;
32
- export declare function setCreateComment(createCommentImpl: createCommentFunc): void;
33
- declare type nextSiblingFunc = (node: N) => N | null;
34
- export declare let nextSibling: nextSiblingFunc;
35
- export declare function setNextSibling(nextSiblingImpl: nextSiblingFunc): void;
36
- declare type attachShadowFunc = (element: E, options: ShadowRootInit) => N;
37
- export declare let attachShadow: attachShadowFunc;
38
- export declare function setAttachShadow(attachShadowImpl: attachShadowFunc): void;
39
- declare type getPropertyFunc = (node: N, key: string) => any;
40
- export declare let getProperty: getPropertyFunc;
41
- export declare function setGetProperty(getPropertyImpl: getPropertyFunc): void;
42
- declare type setPropertyFunc = (node: N, key: string, value: any) => void;
43
- export declare let setProperty: setPropertyFunc;
44
- export declare function setSetProperty(setPropertyImpl: setPropertyFunc): void;
45
- declare type setTextFunc = (node: N, content: string) => void;
46
- export declare let setText: setTextFunc;
47
- export declare function setSetText(setTextImpl: setTextFunc): void;
48
- declare type getAttributeFunc = (element: E, name: string, namespace?: string | null) => string | null;
49
- export declare let getAttribute: getAttributeFunc;
50
- export declare function setGetAttribute(getAttributeImpl: getAttributeFunc): void;
51
- declare type setAttributeFunc = (element: E, name: string, value: string, namespace?: string | null) => void;
52
- export declare let setAttribute: setAttributeFunc;
53
- export declare function setSetAttribute(setAttributeImpl: setAttributeFunc): void;
54
- declare type removeAttributeFunc = (element: E, name: string, namespace?: string | null) => void;
55
- export declare let removeAttribute: removeAttributeFunc;
56
- export declare function setRemoveAttribute(removeAttributeImpl: removeAttributeFunc): void;
57
- declare type addEventListenerFunc = (target: N, type: string, callback: (event: Event) => any, options?: AddEventListenerOptions | boolean) => void;
58
- export declare let addEventListener: addEventListenerFunc;
59
- export declare function setAddEventListener(addEventListenerImpl: addEventListenerFunc): void;
60
- declare type removeEventListenerFunc = (target: N, type: string, callback: (event: Event) => any, options?: EventListenerOptions | boolean) => void;
61
- export declare let removeEventListener: removeEventListenerFunc;
62
- export declare function setRemoveEventListener(removeEventListenerImpl: removeEventListenerFunc): void;
63
- declare type dispatchEventFunc = (target: N, event: Event) => boolean;
64
- export declare let dispatchEvent: dispatchEventFunc;
65
- export declare function setDispatchEvent(dispatchEventImpl: dispatchEventFunc): void;
66
- declare type getClassListFunc = (element: E) => DOMTokenList;
67
- export declare let getClassList: getClassListFunc;
68
- export declare function setGetClassList(getClassListImpl: getClassListFunc): void;
69
- declare type setCSSStylePropertyFunc = (element: E, name: string, value: string, important: boolean) => void;
70
- export declare let setCSSStyleProperty: setCSSStylePropertyFunc;
71
- export declare function setSetCSSStyleProperty(setCSSStylePropertyImpl: setCSSStylePropertyFunc): void;
72
- declare type getBoundingClientRectFunc = (element: E) => ClientRect;
73
- export declare let getBoundingClientRect: getBoundingClientRectFunc;
74
- export declare function setGetBoundingClientRect(getBoundingClientRectImpl: getBoundingClientRectFunc): void;
75
- declare type querySelectorFunc = (element: E, selectors: string) => E | null;
76
- export declare let querySelector: querySelectorFunc;
77
- export declare function setQuerySelector(querySelectorImpl: querySelectorFunc): void;
78
- declare type querySelectorAllFunc = (element: E, selectors: string) => NodeList;
79
- export declare let querySelectorAll: querySelectorAllFunc;
80
- export declare function setQuerySelectorAll(querySelectorAllImpl: querySelectorAllFunc): void;
81
- declare type getElementsByTagNameFunc = (element: E, tagNameOrWildCard: string) => HTMLCollection;
82
- export declare let getElementsByTagName: getElementsByTagNameFunc;
83
- export declare function setGetElementsByTagName(getElementsByTagNameImpl: getElementsByTagNameFunc): void;
84
- declare type getElementsByClassNameFunc = (element: E, names: string) => HTMLCollection;
85
- export declare let getElementsByClassName: getElementsByClassNameFunc;
86
- export declare function setGetElementsByClassName(getElementsByClassNameImpl: getElementsByClassNameFunc): void;
87
- declare type getChildrenFunc = (element: E) => HTMLCollection;
88
- export declare let getChildren: getChildrenFunc;
89
- export declare function setGetChildren(getChildrenImpl: getChildrenFunc): void;
90
- declare type getChildNodesFunc = (element: E) => NodeList;
91
- export declare let getChildNodes: getChildNodesFunc;
92
- export declare function setGetChildNodes(getChildNodesImpl: getChildNodesFunc): void;
93
- declare type getFirstChildFunc = (element: E) => N | null;
94
- export declare let getFirstChild: getFirstChildFunc;
95
- export declare function setGetFirstChild(getFirstChildImpl: getFirstChildFunc): void;
96
- declare type getFirstElementChildFunc = (element: E) => E | null;
97
- export declare let getFirstElementChild: getFirstElementChildFunc;
98
- export declare function setGetFirstElementChild(getFirstElementChildImpl: getFirstElementChildFunc): void;
99
- declare type getLastChildFunc = (element: E) => N | null;
100
- export declare let getLastChild: getLastChildFunc;
101
- export declare function setGetLastChild(getLastChildImpl: getLastChildFunc): void;
102
- declare type getLastElementChildFunc = (element: E) => E | null;
103
- export declare let getLastElementChild: getLastElementChildFunc;
104
- export declare function setGetLastElementChild(getLastElementChildImpl: getLastElementChildFunc): void;
105
- declare type isConnectedFunc = (node: N) => boolean;
106
- export declare let isConnected: isConnectedFunc;
107
- export declare function setIsConnected(isConnectedImpl: isConnectedFunc): void;
108
- declare type insertStylesheetFunc = (content: string, target?: ShadowRoot) => void;
109
- export declare let insertStylesheet: insertStylesheetFunc;
110
- export declare function setInsertStylesheet(insertStylesheetImpl: insertStylesheetFunc): void;
111
- declare type assertInstanceOfHTMLElementFunc = (elm: any, msg: string) => void;
112
- export declare let assertInstanceOfHTMLElement: assertInstanceOfHTMLElementFunc;
113
- export declare function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl: assertInstanceOfHTMLElementFunc): void;
114
- declare type defineCustomElementFunc = (name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions) => void;
115
- export declare let defineCustomElement: defineCustomElementFunc;
116
- export declare function setDefineCustomElement(defineCustomElementImpl: defineCustomElementFunc): void;
117
- declare type getCustomElementFunc = (name: string) => CustomElementConstructor | undefined;
118
- export declare let getCustomElement: getCustomElementFunc;
119
- export declare function setGetCustomElement(getCustomElementImpl: getCustomElementFunc): void;