@lwc/engine-core 5.0.3 → 5.1.1-alpha.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.
- package/dist/framework/modules/attrs.d.ts +2 -1
- package/dist/framework/renderer.d.ts +2 -2
- package/dist/framework/reporting.d.ts +1 -7
- package/dist/framework/vnodes.d.ts +4 -0
- package/dist/index.cjs.js +49 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +49 -45
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { RendererAPI } from '../renderer';
|
|
2
|
-
import { VBaseElement } from '../vnodes';
|
|
2
|
+
import { VBaseElement, VStatic } from '../vnodes';
|
|
3
3
|
export declare function patchAttributes(oldVnode: VBaseElement | null, vnode: VBaseElement, renderer: RendererAPI): void;
|
|
4
|
+
export declare function patchSlotAssignment(oldVnode: VBaseElement | VStatic | null, vnode: VBaseElement | VStatic, renderer: RendererAPI): void;
|
|
@@ -42,8 +42,8 @@ export interface RendererAPI {
|
|
|
42
42
|
isConnected: (node: N) => boolean;
|
|
43
43
|
insertStylesheet: (content: string, target?: ShadowRoot) => void;
|
|
44
44
|
assertInstanceOfHTMLElement: (elm: any, msg: string) => void;
|
|
45
|
-
createCustomElement: (tagName: string, upgradeCallback: LifecycleCallback
|
|
46
|
-
defineCustomElement: (tagName: string
|
|
45
|
+
createCustomElement: (tagName: string, upgradeCallback: LifecycleCallback) => E;
|
|
46
|
+
defineCustomElement: (tagName: string) => void;
|
|
47
47
|
ownerDocument(elm: E): Document;
|
|
48
48
|
registerContextConsumer: (element: E, adapterContextToken: string, subscriptionPayload: WireContextSubscriptionPayload) => void;
|
|
49
49
|
attachInternals: (elm: E) => ElementInternals;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ShadowMode } from './vm';
|
|
2
1
|
export declare const enum ReportingEventId {
|
|
3
2
|
CrossRootAriaInSyntheticShadow = "CrossRootAriaInSyntheticShadow",
|
|
4
3
|
CompilerRuntimeVersionMismatch = "CompilerRuntimeVersionMismatch",
|
|
5
4
|
NonStandardAriaReflection = "NonStandardAriaReflection",
|
|
6
5
|
TemplateMutation = "TemplateMutation",
|
|
7
6
|
StylesheetMutation = "StylesheetMutation",
|
|
8
|
-
ConnectedCallbackWhileDisconnected = "ConnectedCallbackWhileDisconnected"
|
|
9
|
-
ShadowModeUsage = "ShadowModeUsage"
|
|
7
|
+
ConnectedCallbackWhileDisconnected = "ConnectedCallbackWhileDisconnected"
|
|
10
8
|
}
|
|
11
9
|
export interface BasePayload {
|
|
12
10
|
tagName?: string;
|
|
@@ -31,9 +29,6 @@ export interface StylesheetMutationPayload extends BasePayload {
|
|
|
31
29
|
}
|
|
32
30
|
export interface ConnectedCallbackWhileDisconnectedPayload extends BasePayload {
|
|
33
31
|
}
|
|
34
|
-
export interface ShadowModeUsagePayload extends BasePayload {
|
|
35
|
-
mode: ShadowMode;
|
|
36
|
-
}
|
|
37
32
|
export type ReportingPayloadMapping = {
|
|
38
33
|
[ReportingEventId.CrossRootAriaInSyntheticShadow]: CrossRootAriaInSyntheticShadowPayload;
|
|
39
34
|
[ReportingEventId.CompilerRuntimeVersionMismatch]: CompilerRuntimeVersionMismatchPayload;
|
|
@@ -41,7 +36,6 @@ export type ReportingPayloadMapping = {
|
|
|
41
36
|
[ReportingEventId.TemplateMutation]: TemplateMutationPayload;
|
|
42
37
|
[ReportingEventId.StylesheetMutation]: StylesheetMutationPayload;
|
|
43
38
|
[ReportingEventId.ConnectedCallbackWhileDisconnected]: ConnectedCallbackWhileDisconnectedPayload;
|
|
44
|
-
[ReportingEventId.ShadowModeUsage]: ShadowModeUsagePayload;
|
|
45
39
|
};
|
|
46
40
|
export type ReportingDispatcher<T extends ReportingEventId = ReportingEventId> = (reportingEventId: T, payload: ReportingPayloadMapping[T]) => void;
|
|
47
41
|
/** Callbacks to invoke when reporting is enabled **/
|
|
@@ -40,6 +40,7 @@ export interface VStatic extends BaseVNode {
|
|
|
40
40
|
readonly fragment: Element;
|
|
41
41
|
readonly parts: VStaticPart[] | undefined;
|
|
42
42
|
elm: Element | undefined;
|
|
43
|
+
slotAssignment: string | undefined;
|
|
43
44
|
}
|
|
44
45
|
export interface VFragment extends BaseVNode, BaseVParent {
|
|
45
46
|
sel: undefined;
|
|
@@ -65,6 +66,7 @@ export interface VBaseElement extends BaseVNode, BaseVParent {
|
|
|
65
66
|
data: VElementData;
|
|
66
67
|
elm: Element | undefined;
|
|
67
68
|
key: Key;
|
|
69
|
+
slotAssignment: string | undefined;
|
|
68
70
|
}
|
|
69
71
|
export interface VElement extends VBaseElement {
|
|
70
72
|
type: VNodeType.Element;
|
|
@@ -93,9 +95,11 @@ export interface VElementData extends VNodeData {
|
|
|
93
95
|
readonly external?: boolean;
|
|
94
96
|
readonly ref?: string;
|
|
95
97
|
readonly slotData?: any;
|
|
98
|
+
readonly slotAssignment?: string;
|
|
96
99
|
}
|
|
97
100
|
export declare function isVBaseElement(vnode: VNode): vnode is VElement | VCustomElement;
|
|
98
101
|
export declare function isSameVnode(vnode1: VNode, vnode2: VNode): boolean;
|
|
99
102
|
export declare function isVCustomElement(vnode: VNode | VBaseElement): vnode is VCustomElement;
|
|
100
103
|
export declare function isVFragment(vnode: VNode): vnode is VFragment;
|
|
101
104
|
export declare function isVScopedSlotFragment(vnode: VNode): vnode is VScopedSlotFragment;
|
|
105
|
+
export declare function isVStatic(vnode: VNode): vnode is VStatic;
|
package/dist/index.cjs.js
CHANGED
|
@@ -3507,6 +3507,9 @@ function isVFragment(vnode) {
|
|
|
3507
3507
|
function isVScopedSlotFragment(vnode) {
|
|
3508
3508
|
return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
|
|
3509
3509
|
}
|
|
3510
|
+
function isVStatic(vnode) {
|
|
3511
|
+
return vnode.type === 4 /* VNodeType.Static */;
|
|
3512
|
+
}
|
|
3510
3513
|
|
|
3511
3514
|
/*
|
|
3512
3515
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3555,6 +3558,19 @@ function patchAttributes(oldVnode, vnode, renderer) {
|
|
|
3555
3558
|
}
|
|
3556
3559
|
}
|
|
3557
3560
|
}
|
|
3561
|
+
function patchSlotAssignment(oldVnode, vnode, renderer) {
|
|
3562
|
+
if ((oldVnode === null || oldVnode === void 0 ? void 0 : oldVnode.slotAssignment) === vnode.slotAssignment) {
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
const { elm } = vnode;
|
|
3566
|
+
const { setAttribute, removeAttribute } = renderer;
|
|
3567
|
+
if (shared.isUndefined(vnode.slotAssignment) || shared.isNull(vnode.slotAssignment)) {
|
|
3568
|
+
removeAttribute(elm, 'slot');
|
|
3569
|
+
}
|
|
3570
|
+
else {
|
|
3571
|
+
setAttribute(elm, 'slot', vnode.slotAssignment);
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3558
3574
|
|
|
3559
3575
|
/*
|
|
3560
3576
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4004,6 +4020,8 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
4004
4020
|
}
|
|
4005
4021
|
function patchStatic(n1, n2, renderer) {
|
|
4006
4022
|
const elm = (n2.elm = n1.elm);
|
|
4023
|
+
// slotAssignments can only apply to the top level element, never to a static part.
|
|
4024
|
+
patchSlotAssignment(n1, n2, renderer);
|
|
4007
4025
|
// The `refs` object is blown away in every re-render, so we always need to re-apply them
|
|
4008
4026
|
applyStaticParts(elm, n2, renderer, false);
|
|
4009
4027
|
}
|
|
@@ -4025,6 +4043,8 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
4025
4043
|
elm[shared.KEY__SHADOW_STATIC] = true;
|
|
4026
4044
|
}
|
|
4027
4045
|
}
|
|
4046
|
+
// slotAssignments can only apply to the top level element, never to a static part.
|
|
4047
|
+
patchSlotAssignment(null, vnode, renderer);
|
|
4028
4048
|
insertNode(elm, parent, anchor, renderer);
|
|
4029
4049
|
applyStaticParts(elm, vnode, renderer, true);
|
|
4030
4050
|
}
|
|
@@ -4042,38 +4062,12 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
4042
4062
|
// the custom element from the registry is expecting an upgrade callback
|
|
4043
4063
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
4044
4064
|
};
|
|
4045
|
-
let connectedCallback;
|
|
4046
|
-
let disconnectedCallback;
|
|
4047
|
-
let formAssociatedCallback;
|
|
4048
|
-
let formDisabledCallback;
|
|
4049
|
-
let formResetCallback;
|
|
4050
|
-
let formStateRestoreCallback;
|
|
4051
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4052
|
-
connectedCallback = (elm) => {
|
|
4053
|
-
connectRootElement(elm);
|
|
4054
|
-
};
|
|
4055
|
-
disconnectedCallback = (elm) => {
|
|
4056
|
-
disconnectRootElement(elm);
|
|
4057
|
-
};
|
|
4058
|
-
formAssociatedCallback = (elm) => {
|
|
4059
|
-
runFormAssociatedCallback(elm);
|
|
4060
|
-
};
|
|
4061
|
-
formDisabledCallback = (elm) => {
|
|
4062
|
-
runFormDisabledCallback(elm);
|
|
4063
|
-
};
|
|
4064
|
-
formResetCallback = (elm) => {
|
|
4065
|
-
runFormResetCallback(elm);
|
|
4066
|
-
};
|
|
4067
|
-
formStateRestoreCallback = (elm) => {
|
|
4068
|
-
runFormStateRestoreCallback(elm);
|
|
4069
|
-
};
|
|
4070
|
-
}
|
|
4071
4065
|
// Should never get a tag with upper case letter at this point; the compiler
|
|
4072
4066
|
// should produce only tags with lowercase letters. However, the Java
|
|
4073
4067
|
// compiler may generate tagnames with uppercase letters so - for backwards
|
|
4074
4068
|
// compatibility, we lower case the tagname here.
|
|
4075
4069
|
const normalizedTagname = sel.toLowerCase();
|
|
4076
|
-
const elm = createCustomElement(normalizedTagname, upgradeCallback
|
|
4070
|
+
const elm = createCustomElement(normalizedTagname, upgradeCallback);
|
|
4077
4071
|
vnode.elm = elm;
|
|
4078
4072
|
vnode.vm = vm;
|
|
4079
4073
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -4276,6 +4270,7 @@ function patchElementPropsAndAttrsAndRefs$1(oldVnode, vnode, renderer) {
|
|
|
4276
4270
|
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4277
4271
|
patchAttributes(oldVnode, vnode, renderer);
|
|
4278
4272
|
patchProps(oldVnode, vnode, renderer);
|
|
4273
|
+
patchSlotAssignment(oldVnode, vnode, renderer);
|
|
4279
4274
|
// The `refs` object is blown away in every re-render, so we always need to re-apply them
|
|
4280
4275
|
applyRefs(vnode, vnode.owner);
|
|
4281
4276
|
}
|
|
@@ -4429,7 +4424,7 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4429
4424
|
return vm;
|
|
4430
4425
|
}
|
|
4431
4426
|
function allocateInSlot(vm, children, owner) {
|
|
4432
|
-
var _a
|
|
4427
|
+
var _a;
|
|
4433
4428
|
const { cmpSlots: { slotAssignments: oldSlotsMapping }, } = vm;
|
|
4434
4429
|
const cmpSlotsMapping = shared.create(null);
|
|
4435
4430
|
// Collect all slots into cmpSlotsMapping
|
|
@@ -4439,8 +4434,8 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4439
4434
|
continue;
|
|
4440
4435
|
}
|
|
4441
4436
|
let slotName = '';
|
|
4442
|
-
if (isVBaseElement(vnode)) {
|
|
4443
|
-
slotName = (
|
|
4437
|
+
if (isVBaseElement(vnode) || isVStatic(vnode)) {
|
|
4438
|
+
slotName = (_a = vnode.slotAssignment) !== null && _a !== void 0 ? _a : '';
|
|
4444
4439
|
}
|
|
4445
4440
|
else if (isVScopedSlotFragment(vnode)) {
|
|
4446
4441
|
slotName = vnode.slotName;
|
|
@@ -4710,6 +4705,7 @@ function st(fragment, key, parts) {
|
|
|
4710
4705
|
fragment,
|
|
4711
4706
|
owner,
|
|
4712
4707
|
parts,
|
|
4708
|
+
slotAssignment: undefined,
|
|
4713
4709
|
};
|
|
4714
4710
|
return vnode;
|
|
4715
4711
|
}
|
|
@@ -4754,7 +4750,7 @@ function h(sel, data, children = EmptyArray) {
|
|
|
4754
4750
|
}
|
|
4755
4751
|
});
|
|
4756
4752
|
}
|
|
4757
|
-
const { key } = data;
|
|
4753
|
+
const { key, slotAssignment } = data;
|
|
4758
4754
|
const vnode = {
|
|
4759
4755
|
type: 2 /* VNodeType.Element */,
|
|
4760
4756
|
sel,
|
|
@@ -4763,6 +4759,7 @@ function h(sel, data, children = EmptyArray) {
|
|
|
4763
4759
|
elm: undefined,
|
|
4764
4760
|
key,
|
|
4765
4761
|
owner: vmBeingRendered,
|
|
4762
|
+
slotAssignment,
|
|
4766
4763
|
};
|
|
4767
4764
|
return vnode;
|
|
4768
4765
|
}
|
|
@@ -4787,6 +4784,8 @@ function s(slotName, data, children, slotset) {
|
|
|
4787
4784
|
shared.assert.isTrue(shared.isObject(data), `s() 2nd argument data must be an object.`);
|
|
4788
4785
|
shared.assert.isTrue(shared.isArray(children), `h() 3rd argument children must be an array.`);
|
|
4789
4786
|
}
|
|
4787
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
4788
|
+
const { renderMode } = vmBeingRendered;
|
|
4790
4789
|
if (!shared.isUndefined(slotset) &&
|
|
4791
4790
|
!shared.isUndefined(slotset.slotAssignments) &&
|
|
4792
4791
|
!shared.isUndefined(slotset.slotAssignments[slotName]) &&
|
|
@@ -4809,7 +4808,6 @@ function s(slotName, data, children, slotset) {
|
|
|
4809
4808
|
}
|
|
4810
4809
|
// If the passed slot content is factory, evaluate it and add the produced vnodes
|
|
4811
4810
|
if (assignedNodeIsScopedSlot) {
|
|
4812
|
-
const vmBeingRenderedInception = getVMBeingRendered();
|
|
4813
4811
|
// Evaluate in the scope of the slot content's owner
|
|
4814
4812
|
// if a slotset is provided, there will always be an owner. The only case where owner is
|
|
4815
4813
|
// undefined is for root components, but root components cannot accept slotted content
|
|
@@ -4823,20 +4821,32 @@ function s(slotName, data, children, slotset) {
|
|
|
4823
4821
|
});
|
|
4824
4822
|
}
|
|
4825
4823
|
finally {
|
|
4826
|
-
setVMBeingRendered(
|
|
4824
|
+
setVMBeingRendered(vmBeingRendered);
|
|
4827
4825
|
}
|
|
4828
4826
|
}
|
|
4829
4827
|
else {
|
|
4828
|
+
// This block is for standard slots (non-scoped slots)
|
|
4829
|
+
let clonedVNode;
|
|
4830
|
+
if (renderMode === 0 /* RenderMode.Light */ &&
|
|
4831
|
+
(isVBaseElement(vnode) || isVStatic(vnode)) &&
|
|
4832
|
+
// We only need to copy the vnodes when the slot assignment changes, copying every time causes issues with
|
|
4833
|
+
// disconnected/connected callback firing.
|
|
4834
|
+
vnode.slotAssignment !== data.slotAssignment) {
|
|
4835
|
+
// When the light DOM slot assignment (slot attribute) changes we can't use the same reference
|
|
4836
|
+
// to the vnode because the current way the diffing algo works, it will replace the original reference
|
|
4837
|
+
// to the host element with a new one. This means the new element will be mounted and immediately unmounted.
|
|
4838
|
+
// Creating a copy of the vnode to preserve a reference to the previous host element.
|
|
4839
|
+
clonedVNode = Object.assign(Object.assign({}, vnode), { slotAssignment: data.slotAssignment });
|
|
4840
|
+
}
|
|
4830
4841
|
// If the slot content is standard type, the content is static, no additional
|
|
4831
4842
|
// processing needed on the vnode
|
|
4832
|
-
shared.ArrayPush.call(newChildren, vnode);
|
|
4843
|
+
shared.ArrayPush.call(newChildren, clonedVNode !== null && clonedVNode !== void 0 ? clonedVNode : vnode);
|
|
4833
4844
|
}
|
|
4834
4845
|
}
|
|
4835
4846
|
}
|
|
4836
4847
|
children = newChildren;
|
|
4837
4848
|
}
|
|
4838
|
-
const
|
|
4839
|
-
const { renderMode, shadowMode, apiVersion } = vmBeingRendered;
|
|
4849
|
+
const { shadowMode, apiVersion } = vmBeingRendered;
|
|
4840
4850
|
if (renderMode === 0 /* RenderMode.Light */) {
|
|
4841
4851
|
// light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
|
|
4842
4852
|
if (shared.isAPIFeatureEnabled(2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */, apiVersion)) {
|
|
@@ -4878,7 +4888,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4878
4888
|
});
|
|
4879
4889
|
}
|
|
4880
4890
|
}
|
|
4881
|
-
const { key } = data;
|
|
4891
|
+
const { key, slotAssignment } = data;
|
|
4882
4892
|
let elm, aChildren, vm;
|
|
4883
4893
|
const vnode = {
|
|
4884
4894
|
type: 3 /* VNodeType.CustomElement */,
|
|
@@ -4887,6 +4897,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4887
4897
|
children,
|
|
4888
4898
|
elm,
|
|
4889
4899
|
key,
|
|
4900
|
+
slotAssignment,
|
|
4890
4901
|
ctor: Ctor,
|
|
4891
4902
|
owner: vmBeingRendered,
|
|
4892
4903
|
mode: 'open',
|
|
@@ -5810,13 +5821,6 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5810
5821
|
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5811
5822
|
vm.shadowMode = computeShadowMode(def, vm.owner, renderer);
|
|
5812
5823
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5813
|
-
// We don't need to report the shadow mode if we're rendering in light DOM
|
|
5814
|
-
if (isReportingEnabled() && vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
5815
|
-
report("ShadowModeUsage" /* ReportingEventId.ShadowModeUsage */, {
|
|
5816
|
-
tagName: vm.tagName,
|
|
5817
|
-
mode: vm.shadowMode,
|
|
5818
|
-
});
|
|
5819
|
-
}
|
|
5820
5824
|
if (process.env.NODE_ENV !== 'production') {
|
|
5821
5825
|
vm.toString = () => {
|
|
5822
5826
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
@@ -7359,5 +7363,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
7359
7363
|
exports.track = track;
|
|
7360
7364
|
exports.unwrap = unwrap;
|
|
7361
7365
|
exports.wire = wire;
|
|
7362
|
-
/** version: 5.0
|
|
7366
|
+
/** version: 5.1.0 */
|
|
7363
7367
|
//# sourceMappingURL=index.cjs.js.map
|