@lwc/engine-core 4.0.0 → 5.0.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/reporting.d.ts +9 -1
- package/dist/framework/vnodes.d.ts +2 -2
- package/dist/index.cjs.js +58 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +58 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -3,7 +3,8 @@ export declare const enum ReportingEventId {
|
|
|
3
3
|
CompilerRuntimeVersionMismatch = "CompilerRuntimeVersionMismatch",
|
|
4
4
|
NonStandardAriaReflection = "NonStandardAriaReflection",
|
|
5
5
|
TemplateMutation = "TemplateMutation",
|
|
6
|
-
StylesheetMutation = "StylesheetMutation"
|
|
6
|
+
StylesheetMutation = "StylesheetMutation",
|
|
7
|
+
ConnectedCallbackWhileDisconnected = "ConnectedCallbackWhileDisconnected"
|
|
7
8
|
}
|
|
8
9
|
export interface BasePayload {
|
|
9
10
|
tagName?: string;
|
|
@@ -26,12 +27,15 @@ export interface TemplateMutationPayload extends BasePayload {
|
|
|
26
27
|
export interface StylesheetMutationPayload extends BasePayload {
|
|
27
28
|
propertyName: string;
|
|
28
29
|
}
|
|
30
|
+
export interface ConnectedCallbackWhileDisconnectedPayload extends BasePayload {
|
|
31
|
+
}
|
|
29
32
|
export type ReportingPayloadMapping = {
|
|
30
33
|
[ReportingEventId.CrossRootAriaInSyntheticShadow]: CrossRootAriaInSyntheticShadowPayload;
|
|
31
34
|
[ReportingEventId.CompilerRuntimeVersionMismatch]: CompilerRuntimeVersionMismatchPayload;
|
|
32
35
|
[ReportingEventId.NonStandardAriaReflection]: NonStandardAriaReflectionPayload;
|
|
33
36
|
[ReportingEventId.TemplateMutation]: TemplateMutationPayload;
|
|
34
37
|
[ReportingEventId.StylesheetMutation]: StylesheetMutationPayload;
|
|
38
|
+
[ReportingEventId.ConnectedCallbackWhileDisconnected]: ConnectedCallbackWhileDisconnectedPayload;
|
|
35
39
|
};
|
|
36
40
|
export type ReportingDispatcher<T extends ReportingEventId = ReportingEventId> = (reportingEventId: T, payload: ReportingPayloadMapping[T]) => void;
|
|
37
41
|
/** Callbacks to invoke when reporting is enabled **/
|
|
@@ -60,4 +64,8 @@ export declare function onReportingEnabled(callback: OnReportingEnabledCallback)
|
|
|
60
64
|
* @param payload - data to report
|
|
61
65
|
*/
|
|
62
66
|
export declare function report<T extends ReportingEventId>(reportingEventId: T, payload: ReportingPayloadMapping[T]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Return true if reporting is enabled
|
|
69
|
+
*/
|
|
70
|
+
export declare function isReportingEnabled(): boolean;
|
|
63
71
|
export {};
|
|
@@ -45,8 +45,8 @@ export interface VFragment extends BaseVNode, BaseVParent {
|
|
|
45
45
|
sel: undefined;
|
|
46
46
|
type: VNodeType.Fragment;
|
|
47
47
|
stable: 0 | 1;
|
|
48
|
-
leading: VText;
|
|
49
|
-
trailing: VText;
|
|
48
|
+
leading: VText | VComment;
|
|
49
|
+
trailing: VText | VComment;
|
|
50
50
|
}
|
|
51
51
|
export interface VText extends BaseVNode {
|
|
52
52
|
type: VNodeType.Text;
|
package/dist/index.cjs.js
CHANGED
|
@@ -78,6 +78,12 @@ function report(reportingEventId, payload) {
|
|
|
78
78
|
currentDispatcher$1(reportingEventId, payload);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Return true if reporting is enabled
|
|
83
|
+
*/
|
|
84
|
+
function isReportingEnabled() {
|
|
85
|
+
return enabled$1;
|
|
86
|
+
}
|
|
81
87
|
|
|
82
88
|
/*
|
|
83
89
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4161,17 +4167,16 @@ function unmount(vnode, parent, renderer, doRemove = false) {
|
|
|
4161
4167
|
const { type, elm, sel } = vnode;
|
|
4162
4168
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4163
4169
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
4164
|
-
if (doRemove) {
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
else {
|
|
4169
|
-
// The vnode might or might not have a data.renderer associated to it
|
|
4170
|
-
// but the removal used here is from the owner instead.
|
|
4171
|
-
removeNode(elm, parent, renderer);
|
|
4172
|
-
}
|
|
4170
|
+
if (doRemove && type !== 5 /* VNodeType.Fragment */) {
|
|
4171
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
4172
|
+
// but the removal used here is from the owner instead.
|
|
4173
|
+
removeNode(elm, parent, renderer);
|
|
4173
4174
|
}
|
|
4174
4175
|
switch (type) {
|
|
4176
|
+
case 5 /* VNodeType.Fragment */: {
|
|
4177
|
+
unmountVNodes(vnode.children, parent, renderer, doRemove);
|
|
4178
|
+
break;
|
|
4179
|
+
}
|
|
4175
4180
|
case 2 /* VNodeType.Element */: {
|
|
4176
4181
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4177
4182
|
// Only required for synthetic shadow.
|
|
@@ -4710,8 +4715,10 @@ function st(fragment, key, parts) {
|
|
|
4710
4715
|
}
|
|
4711
4716
|
// [fr]agment node
|
|
4712
4717
|
function fr(key, children, stable) {
|
|
4713
|
-
const
|
|
4714
|
-
const
|
|
4718
|
+
const owner = getVMBeingRendered();
|
|
4719
|
+
const useCommentNodes = shared.isAPIFeatureEnabled(5 /* APIFeature.USE_COMMENTS_FOR_FRAGMENT_BOOKENDS */, owner.apiVersion);
|
|
4720
|
+
const leading = useCommentNodes ? co('') : t('');
|
|
4721
|
+
const trailing = useCommentNodes ? co('') : t('');
|
|
4715
4722
|
return {
|
|
4716
4723
|
type: 5 /* VNodeType.Fragment */,
|
|
4717
4724
|
sel: undefined,
|
|
@@ -4719,7 +4726,7 @@ function fr(key, children, stable) {
|
|
|
4719
4726
|
elm: undefined,
|
|
4720
4727
|
children: [leading, ...children, trailing],
|
|
4721
4728
|
stable,
|
|
4722
|
-
owner
|
|
4729
|
+
owner,
|
|
4723
4730
|
leading,
|
|
4724
4731
|
trailing,
|
|
4725
4732
|
};
|
|
@@ -6038,6 +6045,24 @@ function runConnectedCallback(vm) {
|
|
|
6038
6045
|
invokeComponentCallback(vm, connectedCallback);
|
|
6039
6046
|
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
6040
6047
|
}
|
|
6048
|
+
// This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
|
|
6049
|
+
// we're in dev mode. This is to detect a particular issue with synthetic lifecycle.
|
|
6050
|
+
if (process.env.IS_BROWSER &&
|
|
6051
|
+
!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE &&
|
|
6052
|
+
(process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
|
|
6053
|
+
if (!vm.renderer.isConnected(vm.elm)) {
|
|
6054
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6055
|
+
logWarnOnce(`Element <${vm.tagName}> ` +
|
|
6056
|
+
`fired a \`connectedCallback\` and rendered, but was not connected to the DOM. ` +
|
|
6057
|
+
`Please ensure all components are actually connected to the DOM, e.g. using ` +
|
|
6058
|
+
`\`document.body.appendChild(element)\`. This will not be supported in future versions of ` +
|
|
6059
|
+
`LWC and could cause component errors. For details, see: https://sfdc.co/synthetic-lifecycle`);
|
|
6060
|
+
}
|
|
6061
|
+
report("ConnectedCallbackWhileDisconnected" /* ReportingEventId.ConnectedCallbackWhileDisconnected */, {
|
|
6062
|
+
tagName: vm.tagName,
|
|
6063
|
+
});
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
6041
6066
|
}
|
|
6042
6067
|
function hasWireAdapters(vm) {
|
|
6043
6068
|
return shared.getOwnPropertyNames(vm.def.wire).length > 0;
|
|
@@ -6547,7 +6572,7 @@ function hydrateVM(vm) {
|
|
|
6547
6572
|
// reset the refs; they will be set during `hydrateChildren`
|
|
6548
6573
|
resetRefVNodes(vm);
|
|
6549
6574
|
const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
|
|
6550
|
-
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
6575
|
+
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm, false);
|
|
6551
6576
|
runRenderedCallback(vm);
|
|
6552
6577
|
}
|
|
6553
6578
|
function hydrateNode(node, vnode, renderer) {
|
|
@@ -6659,7 +6684,7 @@ function hydrateStaticElement(elm, vnode, renderer) {
|
|
|
6659
6684
|
}
|
|
6660
6685
|
function hydrateFragment(elm, vnode, renderer) {
|
|
6661
6686
|
const { children, owner } = vnode;
|
|
6662
|
-
hydrateChildren(elm, children, renderer.getProperty(elm, 'parentNode'), owner);
|
|
6687
|
+
hydrateChildren(elm, children, renderer.getProperty(elm, 'parentNode'), owner, true);
|
|
6663
6688
|
return (vnode.elm = children[children.length - 1].elm);
|
|
6664
6689
|
}
|
|
6665
6690
|
function hydrateElement(elm, vnode, renderer) {
|
|
@@ -6691,7 +6716,7 @@ function hydrateElement(elm, vnode, renderer) {
|
|
|
6691
6716
|
patchElementPropsAndAttrsAndRefs(vnode, renderer);
|
|
6692
6717
|
if (!isDomManual) {
|
|
6693
6718
|
const { getFirstChild } = renderer;
|
|
6694
|
-
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner);
|
|
6719
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, owner, false);
|
|
6695
6720
|
}
|
|
6696
6721
|
return elm;
|
|
6697
6722
|
}
|
|
@@ -6733,12 +6758,16 @@ function hydrateCustomElement(elm, vnode, renderer) {
|
|
|
6733
6758
|
const { getFirstChild } = renderer;
|
|
6734
6759
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6735
6760
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6736
|
-
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
6761
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm, false);
|
|
6737
6762
|
}
|
|
6738
6763
|
hydrateVM(vm);
|
|
6739
6764
|
return elm;
|
|
6740
6765
|
}
|
|
6741
|
-
function hydrateChildren(node, children, parentNode, owner
|
|
6766
|
+
function hydrateChildren(node, children, parentNode, owner,
|
|
6767
|
+
// When rendering the children of a VFragment, additional siblings may follow the
|
|
6768
|
+
// last node of the fragment. Hydration should not fail if a trailing sibling is
|
|
6769
|
+
// found in this case.
|
|
6770
|
+
expectAddlSiblings) {
|
|
6742
6771
|
let hasWarned = false;
|
|
6743
6772
|
let nextNode = node;
|
|
6744
6773
|
const { renderer } = owner;
|
|
@@ -6761,7 +6790,17 @@ function hydrateChildren(node, children, parentNode, owner) {
|
|
|
6761
6790
|
}
|
|
6762
6791
|
}
|
|
6763
6792
|
}
|
|
6764
|
-
|
|
6793
|
+
const useCommentsForBookends = shared.isAPIFeatureEnabled(5 /* APIFeature.USE_COMMENTS_FOR_FRAGMENT_BOOKENDS */, owner.apiVersion);
|
|
6794
|
+
if (
|
|
6795
|
+
// If 1) comments are used for bookends, and 2) we're not expecting additional siblings,
|
|
6796
|
+
// and 3) there exists an additional sibling, that's a hydration failure.
|
|
6797
|
+
//
|
|
6798
|
+
// This preserves the previous behavior for text-node bookends where mismatches
|
|
6799
|
+
// would incorrectly occur but which is unfortunately baked into the SSR hydration
|
|
6800
|
+
// contract. It also preserves the behavior of valid hydration failures where the server
|
|
6801
|
+
// rendered more nodes than the client.
|
|
6802
|
+
(!useCommentsForBookends || !expectAddlSiblings) &&
|
|
6803
|
+
nextNode) {
|
|
6765
6804
|
hasMismatch = true;
|
|
6766
6805
|
if (process.env.NODE_ENV !== 'production') {
|
|
6767
6806
|
if (!hasWarned) {
|
|
@@ -7313,5 +7352,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
7313
7352
|
exports.track = track;
|
|
7314
7353
|
exports.unwrap = unwrap;
|
|
7315
7354
|
exports.wire = wire;
|
|
7316
|
-
/** version:
|
|
7355
|
+
/** version: 5.0.0 */
|
|
7317
7356
|
//# sourceMappingURL=index.cjs.js.map
|