@lwc/engine-core 2.27.0 → 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.
@@ -3756,9 +3756,14 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3756
3756
  if (features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3757
3757
  disconnectRootElement(elm);
3758
3758
  }
3759
- };
3759
+ }; // Should never get a tag with upper case letter at this point; the compiler
3760
+ // should produce only tags with lowercase letters. However, the Java
3761
+ // compiler may generate tagnames with uppercase letters so - for backwards
3762
+ // compatibility, we lower case the tagname here.
3763
+
3760
3764
 
3761
- const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
3765
+ const normalizedTagname = sel.toLowerCase();
3766
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
3762
3767
  vnode.elm = elm;
3763
3768
  vnode.vm = vm;
3764
3769
  linkNodeToShadow(elm, owner, renderer);
@@ -4064,6 +4069,17 @@ function allocateChildren(vnode, vm) {
4064
4069
  shadowMode
4065
4070
  } = vm;
4066
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
+
4067
4083
  if (shadowMode === 1
4068
4084
  /* ShadowMode.Synthetic */
4069
4085
  || renderMode === 0
@@ -4458,27 +4474,42 @@ function s(slotName, data, children, slotset) {
4458
4474
  !shared.isUndefined(slotset.slotAssignments) &&
4459
4475
  !shared.isUndefined(slotset.slotAssignments[slotName]) &&
4460
4476
  slotset.slotAssignments[slotName].length !== 0) {
4461
- children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
4462
- // If the passed slot content is factory, evaluate it and use the produced vnodes
4463
- if (vnode && isVScopedSlotFragment(vnode)) {
4464
- const vmBeingRenderedInception = getVMBeingRendered();
4465
- let children = [];
4466
- // Evaluate in the scope of the slot content's owner
4467
- // if a slotset is provided, there will always be an owner. The only case where owner is
4468
- // undefined is for root components, but root components cannot accept slotted content
4469
- setVMBeingRendered(slotset.owner);
4470
- try {
4471
- children = vnode.factory(data.slotData);
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;
4472
4489
  }
4473
- finally {
4474
- setVMBeingRendered(vmBeingRenderedInception);
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);
4475
4510
  }
4476
- return shared.ArrayConcat.call(acc, children);
4477
- }
4478
- else {
4479
- // If the slot content is a static list of child nodes provided by the parent, nothing to do
4480
- return shared.ArrayConcat.call(acc, vnode);
4481
4511
  }
4512
+ return accumulator;
4482
4513
  }, []);
4483
4514
  }
4484
4515
  const vmBeingRendered = getVMBeingRendered();
@@ -6888,4 +6919,4 @@ exports.swapTemplate = swapTemplate;
6888
6919
  exports.track = track;
6889
6920
  exports.unwrap = unwrap;
6890
6921
  exports.wire = wire;
6891
- /* version: 2.27.0 */
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, ArrayConcat as ArrayConcat$1, 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.
@@ -3753,9 +3753,14 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3753
3753
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3754
3754
  disconnectRootElement(elm);
3755
3755
  }
3756
- };
3756
+ }; // Should never get a tag with upper case letter at this point; the compiler
3757
+ // should produce only tags with lowercase letters. However, the Java
3758
+ // compiler may generate tagnames with uppercase letters so - for backwards
3759
+ // compatibility, we lower case the tagname here.
3760
+
3757
3761
 
3758
- const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
3762
+ const normalizedTagname = sel.toLowerCase();
3763
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
3759
3764
  vnode.elm = elm;
3760
3765
  vnode.vm = vm;
3761
3766
  linkNodeToShadow(elm, owner, renderer);
@@ -4061,6 +4066,17 @@ function allocateChildren(vnode, vm) {
4061
4066
  shadowMode
4062
4067
  } = vm;
4063
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
+
4064
4080
  if (shadowMode === 1
4065
4081
  /* ShadowMode.Synthetic */
4066
4082
  || renderMode === 0
@@ -4455,27 +4471,42 @@ function s(slotName, data, children, slotset) {
4455
4471
  !isUndefined$1(slotset.slotAssignments) &&
4456
4472
  !isUndefined$1(slotset.slotAssignments[slotName]) &&
4457
4473
  slotset.slotAssignments[slotName].length !== 0) {
4458
- children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
4459
- // If the passed slot content is factory, evaluate it and use the produced vnodes
4460
- if (vnode && isVScopedSlotFragment(vnode)) {
4461
- const vmBeingRenderedInception = getVMBeingRendered();
4462
- let children = [];
4463
- // Evaluate in the scope of the slot content's owner
4464
- // if a slotset is provided, there will always be an owner. The only case where owner is
4465
- // undefined is for root components, but root components cannot accept slotted content
4466
- setVMBeingRendered(slotset.owner);
4467
- try {
4468
- children = vnode.factory(data.slotData);
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;
4469
4486
  }
4470
- finally {
4471
- setVMBeingRendered(vmBeingRenderedInception);
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);
4472
4507
  }
4473
- return ArrayConcat$1.call(acc, children);
4474
- }
4475
- else {
4476
- // If the slot content is a static list of child nodes provided by the parent, nothing to do
4477
- return ArrayConcat$1.call(acc, vnode);
4478
4508
  }
4509
+ return accumulator;
4479
4510
  }, []);
4480
4511
  }
4481
4512
  const vmBeingRendered = getVMBeingRendered();
@@ -6849,4 +6880,4 @@ function getComponentConstructor(elm) {
6849
6880
  }
6850
6881
 
6851
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 };
6852
- /* version: 2.27.0 */
6883
+ /* version: 2.28.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.27.0",
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.27.0",
28
- "@lwc/shared": "2.27.0"
27
+ "@lwc/features": "2.28.0",
28
+ "@lwc/shared": "2.28.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "observable-membrane": "2.0.0"