@lwc/engine-core 2.11.1 → 2.11.5
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/engine-core.cjs.js +324 -253
- package/dist/engine-core.js +325 -254
- package/package.json +4 -5
- package/types/framework/hydration.d.ts +1 -2
- package/types/framework/main.d.ts +2 -1
- package/types/framework/rendering.d.ts +3 -1
- package/types/framework/vm.d.ts +1 -2
package/dist/engine-core.cjs.js
CHANGED
|
@@ -2307,6 +2307,12 @@ function checkVersionMismatch(func, type) {
|
|
|
2307
2307
|
}
|
|
2308
2308
|
}
|
|
2309
2309
|
|
|
2310
|
+
/*
|
|
2311
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2312
|
+
* All rights reserved.
|
|
2313
|
+
* SPDX-License-Identifier: MIT
|
|
2314
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2315
|
+
*/
|
|
2310
2316
|
const signedTemplateSet = new Set();
|
|
2311
2317
|
function defaultEmptyTemplate() {
|
|
2312
2318
|
return [];
|
|
@@ -2324,6 +2330,30 @@ function registerTemplate(tpl) {
|
|
|
2324
2330
|
checkVersionMismatch(tpl, 'template');
|
|
2325
2331
|
}
|
|
2326
2332
|
signedTemplateSet.add(tpl);
|
|
2333
|
+
// FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
|
|
2334
|
+
// the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
|
|
2335
|
+
// on top of stylesheetToken for anyone who is accessing the old internal API.
|
|
2336
|
+
// Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
2337
|
+
shared.defineProperty(tpl, 'stylesheetTokens', {
|
|
2338
|
+
get() {
|
|
2339
|
+
const { stylesheetToken } = this;
|
|
2340
|
+
if (shared.isUndefined(stylesheetToken)) {
|
|
2341
|
+
return stylesheetToken;
|
|
2342
|
+
}
|
|
2343
|
+
// Shim for the old `stylesheetTokens` property
|
|
2344
|
+
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
2345
|
+
return {
|
|
2346
|
+
hostAttribute: `${stylesheetToken}-host`,
|
|
2347
|
+
shadowAttribute: stylesheetToken,
|
|
2348
|
+
};
|
|
2349
|
+
},
|
|
2350
|
+
set(value) {
|
|
2351
|
+
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
2352
|
+
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
2353
|
+
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
2354
|
+
this.stylesheetToken = shared.isUndefined(value) ? undefined : value.shadowAttribute;
|
|
2355
|
+
},
|
|
2356
|
+
});
|
|
2327
2357
|
// chaining this method as a way to wrap existing
|
|
2328
2358
|
// assignment of templates easily, without too much transformation
|
|
2329
2359
|
return tpl;
|
|
@@ -4802,236 +4832,6 @@ function invokeServiceHook(vm, cbs) {
|
|
|
4802
4832
|
}
|
|
4803
4833
|
}
|
|
4804
4834
|
|
|
4805
|
-
/*
|
|
4806
|
-
* Copyright (c) 2022, salesforce.com, inc.
|
|
4807
|
-
* All rights reserved.
|
|
4808
|
-
* SPDX-License-Identifier: MIT
|
|
4809
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4810
|
-
*/
|
|
4811
|
-
function hydrate(vnode, node) {
|
|
4812
|
-
switch (vnode.type) {
|
|
4813
|
-
case 0 /* Text */:
|
|
4814
|
-
hydrateText(vnode, node);
|
|
4815
|
-
break;
|
|
4816
|
-
case 1 /* Comment */:
|
|
4817
|
-
hydrateComment(vnode, node);
|
|
4818
|
-
break;
|
|
4819
|
-
case 2 /* Element */:
|
|
4820
|
-
hydrateElement(vnode, node);
|
|
4821
|
-
break;
|
|
4822
|
-
case 3 /* CustomElement */:
|
|
4823
|
-
hydrateCustomElement(vnode, node);
|
|
4824
|
-
break;
|
|
4825
|
-
}
|
|
4826
|
-
}
|
|
4827
|
-
function hydrateText(vnode, node) {
|
|
4828
|
-
var _a;
|
|
4829
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4830
|
-
validateNodeType(vnode, node, 3 /* TEXT */);
|
|
4831
|
-
const nodeValue = getProperty(node, 'nodeValue');
|
|
4832
|
-
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
4833
|
-
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
4834
|
-
}
|
|
4835
|
-
}
|
|
4836
|
-
// always set the text value to the one from the vnode.
|
|
4837
|
-
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4838
|
-
vnode.elm = node;
|
|
4839
|
-
}
|
|
4840
|
-
function hydrateComment(vnode, node) {
|
|
4841
|
-
var _a;
|
|
4842
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4843
|
-
validateNodeType(vnode, node, 8 /* COMMENT */);
|
|
4844
|
-
if (getProperty(node, 'nodeValue') !== vnode.text) {
|
|
4845
|
-
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
4846
|
-
}
|
|
4847
|
-
}
|
|
4848
|
-
// always set the text value to the one from the vnode.
|
|
4849
|
-
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4850
|
-
vnode.elm = node;
|
|
4851
|
-
}
|
|
4852
|
-
function hydrateElement(vnode, node) {
|
|
4853
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4854
|
-
validateNodeType(vnode, node, 1 /* ELEMENT */);
|
|
4855
|
-
validateElement(vnode, node);
|
|
4856
|
-
}
|
|
4857
|
-
const elm = node;
|
|
4858
|
-
vnode.elm = elm;
|
|
4859
|
-
const { context } = vnode.data;
|
|
4860
|
-
const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
4861
|
-
if (isDomManual) {
|
|
4862
|
-
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
4863
|
-
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
4864
|
-
const { props } = vnode.data;
|
|
4865
|
-
if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
|
|
4866
|
-
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
4867
|
-
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
4868
|
-
vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
|
|
4869
|
-
}
|
|
4870
|
-
else {
|
|
4871
|
-
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
4872
|
-
}
|
|
4873
|
-
}
|
|
4874
|
-
}
|
|
4875
|
-
patchElementPropsAndAttrs(vnode);
|
|
4876
|
-
if (!isDomManual) {
|
|
4877
|
-
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vnode.owner);
|
|
4878
|
-
}
|
|
4879
|
-
}
|
|
4880
|
-
function hydrateCustomElement(vnode, node) {
|
|
4881
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4882
|
-
validateNodeType(vnode, node, 1 /* ELEMENT */);
|
|
4883
|
-
validateElement(vnode, node);
|
|
4884
|
-
}
|
|
4885
|
-
const elm = node;
|
|
4886
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
4887
|
-
const vm = createVM(elm, ctor, {
|
|
4888
|
-
mode,
|
|
4889
|
-
owner,
|
|
4890
|
-
tagName: sel,
|
|
4891
|
-
});
|
|
4892
|
-
vnode.elm = elm;
|
|
4893
|
-
vnode.vm = vm;
|
|
4894
|
-
allocateChildren(vnode, vm);
|
|
4895
|
-
patchElementPropsAndAttrs(vnode);
|
|
4896
|
-
// Insert hook section:
|
|
4897
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4898
|
-
shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
4899
|
-
}
|
|
4900
|
-
runConnectedCallback(vm);
|
|
4901
|
-
if (vm.renderMode !== 0 /* Light */) {
|
|
4902
|
-
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
4903
|
-
// Note: for Light DOM, this is handled while hydrating the VM
|
|
4904
|
-
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vm);
|
|
4905
|
-
}
|
|
4906
|
-
hydrateVM(vm);
|
|
4907
|
-
}
|
|
4908
|
-
function hydrateChildren(elmChildren, children, vm) {
|
|
4909
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4910
|
-
const filteredVNodes = shared.ArrayFilter.call(children, (vnode) => !!vnode);
|
|
4911
|
-
if (elmChildren.length !== filteredVNodes.length) {
|
|
4912
|
-
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4913
|
-
throwHydrationError();
|
|
4914
|
-
}
|
|
4915
|
-
}
|
|
4916
|
-
let childNodeIndex = 0;
|
|
4917
|
-
for (let i = 0; i < children.length; i++) {
|
|
4918
|
-
const childVnode = children[i];
|
|
4919
|
-
if (!shared.isNull(childVnode)) {
|
|
4920
|
-
const childNode = elmChildren[childNodeIndex];
|
|
4921
|
-
hydrate(childVnode, childNode);
|
|
4922
|
-
childNodeIndex++;
|
|
4923
|
-
}
|
|
4924
|
-
}
|
|
4925
|
-
}
|
|
4926
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
4927
|
-
applyEventListeners(vnode);
|
|
4928
|
-
patchProps(null, vnode);
|
|
4929
|
-
}
|
|
4930
|
-
function throwHydrationError() {
|
|
4931
|
-
shared.assert.fail('Server rendered elements do not match client side generated elements');
|
|
4932
|
-
}
|
|
4933
|
-
function validateNodeType(vnode, node, nodeType) {
|
|
4934
|
-
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
4935
|
-
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
4936
|
-
shared.assert.fail('Hydration mismatch: incorrect node type received.');
|
|
4937
|
-
}
|
|
4938
|
-
}
|
|
4939
|
-
function validateElement(vnode, elm) {
|
|
4940
|
-
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
4941
|
-
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
4942
|
-
throwHydrationError();
|
|
4943
|
-
}
|
|
4944
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
4945
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
4946
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
4947
|
-
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
4948
|
-
if (!isVNodeAndElementCompatible) {
|
|
4949
|
-
throwHydrationError();
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4952
|
-
function validateAttrs(vnode, elm) {
|
|
4953
|
-
const { data: { attrs = {} }, } = vnode;
|
|
4954
|
-
let nodesAreCompatible = true;
|
|
4955
|
-
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
4956
|
-
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4957
|
-
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4958
|
-
const elmAttrValue = getAttribute(elm, attrName);
|
|
4959
|
-
if (String(attrValue) !== elmAttrValue) {
|
|
4960
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4961
|
-
nodesAreCompatible = false;
|
|
4962
|
-
}
|
|
4963
|
-
}
|
|
4964
|
-
return nodesAreCompatible;
|
|
4965
|
-
}
|
|
4966
|
-
function validateClassAttr(vnode, elm) {
|
|
4967
|
-
const { data: { className, classMap }, } = vnode;
|
|
4968
|
-
let nodesAreCompatible = true;
|
|
4969
|
-
let vnodeClassName;
|
|
4970
|
-
if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
|
|
4971
|
-
// className is used when class is bound to an expr.
|
|
4972
|
-
nodesAreCompatible = false;
|
|
4973
|
-
vnodeClassName = className;
|
|
4974
|
-
}
|
|
4975
|
-
else if (!shared.isUndefined(classMap)) {
|
|
4976
|
-
// classMap is used when class is set to static value.
|
|
4977
|
-
const classList = getClassList(elm);
|
|
4978
|
-
let computedClassName = '';
|
|
4979
|
-
// all classes from the vnode should be in the element.classList
|
|
4980
|
-
for (const name in classMap) {
|
|
4981
|
-
computedClassName += ' ' + name;
|
|
4982
|
-
if (!classList.contains(name)) {
|
|
4983
|
-
nodesAreCompatible = false;
|
|
4984
|
-
}
|
|
4985
|
-
}
|
|
4986
|
-
vnodeClassName = computedClassName.trim();
|
|
4987
|
-
if (classList.length > shared.keys(classMap).length) {
|
|
4988
|
-
nodesAreCompatible = false;
|
|
4989
|
-
}
|
|
4990
|
-
}
|
|
4991
|
-
if (!nodesAreCompatible) {
|
|
4992
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
|
|
4993
|
-
}
|
|
4994
|
-
return nodesAreCompatible;
|
|
4995
|
-
}
|
|
4996
|
-
function validateStyleAttr(vnode, elm) {
|
|
4997
|
-
const { data: { style, styleDecls }, } = vnode;
|
|
4998
|
-
const elmStyle = getAttribute(elm, 'style') || '';
|
|
4999
|
-
let vnodeStyle;
|
|
5000
|
-
let nodesAreCompatible = true;
|
|
5001
|
-
if (!shared.isUndefined(style) && style !== elmStyle) {
|
|
5002
|
-
nodesAreCompatible = false;
|
|
5003
|
-
vnodeStyle = style;
|
|
5004
|
-
}
|
|
5005
|
-
else if (!shared.isUndefined(styleDecls)) {
|
|
5006
|
-
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
5007
|
-
const expectedStyle = [];
|
|
5008
|
-
// styleMap is used when style is set to static value.
|
|
5009
|
-
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
5010
|
-
const [prop, value, important] = styleDecls[i];
|
|
5011
|
-
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
5012
|
-
const parsedPropValue = parsedVnodeStyle[prop];
|
|
5013
|
-
if (shared.isUndefined(parsedPropValue)) {
|
|
5014
|
-
nodesAreCompatible = false;
|
|
5015
|
-
}
|
|
5016
|
-
else if (!parsedPropValue.startsWith(value)) {
|
|
5017
|
-
nodesAreCompatible = false;
|
|
5018
|
-
}
|
|
5019
|
-
else if (important && !parsedPropValue.endsWith('!important')) {
|
|
5020
|
-
nodesAreCompatible = false;
|
|
5021
|
-
}
|
|
5022
|
-
}
|
|
5023
|
-
if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
5024
|
-
nodesAreCompatible = false;
|
|
5025
|
-
}
|
|
5026
|
-
vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
|
|
5027
|
-
}
|
|
5028
|
-
if (!nodesAreCompatible) {
|
|
5029
|
-
// style is used when class is bound to an expr.
|
|
5030
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
5031
|
-
}
|
|
5032
|
-
return nodesAreCompatible;
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
4835
|
/*
|
|
5036
4836
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5037
4837
|
* All rights reserved.
|
|
@@ -5077,32 +4877,12 @@ function connectRootElement(elm) {
|
|
|
5077
4877
|
/* GlobalHydrate */
|
|
5078
4878
|
, vm);
|
|
5079
4879
|
}
|
|
5080
|
-
function hydrateRootElement(elm) {
|
|
5081
|
-
const vm = getAssociatedVM(elm);
|
|
5082
|
-
runConnectedCallback(vm);
|
|
5083
|
-
hydrateVM(vm);
|
|
5084
|
-
}
|
|
5085
4880
|
function disconnectRootElement(elm) {
|
|
5086
4881
|
const vm = getAssociatedVM(elm);
|
|
5087
4882
|
resetComponentStateWhenRemoved(vm);
|
|
5088
4883
|
}
|
|
5089
4884
|
function appendVM(vm) {
|
|
5090
4885
|
rehydrate(vm);
|
|
5091
|
-
}
|
|
5092
|
-
function hydrateVM(vm) {
|
|
5093
|
-
if (shared.isTrue(vm.isDirty)) {
|
|
5094
|
-
// manually diffing/patching here.
|
|
5095
|
-
// This routine is:
|
|
5096
|
-
// patchShadowRoot(vm, children);
|
|
5097
|
-
// -> addVnodes.
|
|
5098
|
-
const children = renderComponent(vm);
|
|
5099
|
-
vm.children = children;
|
|
5100
|
-
const vmChildren = vm.renderMode === 0
|
|
5101
|
-
/* Light */
|
|
5102
|
-
? getChildNodes(vm.elm) : getChildNodes(vm.elm.shadowRoot);
|
|
5103
|
-
hydrateChildren(vmChildren, children, vm);
|
|
5104
|
-
runRenderedCallback(vm);
|
|
5105
|
-
}
|
|
5106
4886
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
5107
4887
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5108
4888
|
|
|
@@ -5407,7 +5187,6 @@ function runRenderedCallback(vm) {
|
|
|
5407
5187
|
, vm);
|
|
5408
5188
|
}
|
|
5409
5189
|
}
|
|
5410
|
-
|
|
5411
5190
|
let rehydrateQueue = [];
|
|
5412
5191
|
|
|
5413
5192
|
function flushRehydrationQueue() {
|
|
@@ -6064,6 +5843,298 @@ function readonly(obj) {
|
|
|
6064
5843
|
return reactiveMembrane.getReadOnlyProxy(obj);
|
|
6065
5844
|
}
|
|
6066
5845
|
|
|
5846
|
+
/*
|
|
5847
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
5848
|
+
* All rights reserved.
|
|
5849
|
+
* SPDX-License-Identifier: MIT
|
|
5850
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5851
|
+
*/
|
|
5852
|
+
// flag indicating if the hydration recovered from the DOM mismatch
|
|
5853
|
+
let hasMismatch = false;
|
|
5854
|
+
function hydrateRoot(vm) {
|
|
5855
|
+
hasMismatch = false;
|
|
5856
|
+
runConnectedCallback(vm);
|
|
5857
|
+
hydrateVM(vm);
|
|
5858
|
+
if (hasMismatch) {
|
|
5859
|
+
logError('Hydration completed with errors.', vm);
|
|
5860
|
+
}
|
|
5861
|
+
}
|
|
5862
|
+
function hydrateVM(vm) {
|
|
5863
|
+
const children = renderComponent(vm);
|
|
5864
|
+
vm.children = children;
|
|
5865
|
+
const parentNode = vm.renderRoot;
|
|
5866
|
+
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
5867
|
+
runRenderedCallback(vm);
|
|
5868
|
+
}
|
|
5869
|
+
function hydrateNode(node, vnode) {
|
|
5870
|
+
let hydratedNode;
|
|
5871
|
+
switch (vnode.type) {
|
|
5872
|
+
case 0 /* Text */:
|
|
5873
|
+
hydratedNode = hydrateText(node, vnode);
|
|
5874
|
+
break;
|
|
5875
|
+
case 1 /* Comment */:
|
|
5876
|
+
hydratedNode = hydrateComment(node, vnode);
|
|
5877
|
+
break;
|
|
5878
|
+
case 2 /* Element */:
|
|
5879
|
+
hydratedNode = hydrateElement(node, vnode);
|
|
5880
|
+
break;
|
|
5881
|
+
case 3 /* CustomElement */:
|
|
5882
|
+
hydratedNode = hydrateCustomElement(node, vnode);
|
|
5883
|
+
break;
|
|
5884
|
+
}
|
|
5885
|
+
return nextSibling(hydratedNode);
|
|
5886
|
+
}
|
|
5887
|
+
function hydrateText(node, vnode) {
|
|
5888
|
+
var _a;
|
|
5889
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
|
|
5890
|
+
return handleMismatch(node, vnode);
|
|
5891
|
+
}
|
|
5892
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5893
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
5894
|
+
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5895
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5896
|
+
}
|
|
5897
|
+
}
|
|
5898
|
+
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5899
|
+
vnode.elm = node;
|
|
5900
|
+
return node;
|
|
5901
|
+
}
|
|
5902
|
+
function hydrateComment(node, vnode) {
|
|
5903
|
+
var _a;
|
|
5904
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
|
|
5905
|
+
return handleMismatch(node, vnode);
|
|
5906
|
+
}
|
|
5907
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5908
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
5909
|
+
if (nodeValue !== vnode.text) {
|
|
5910
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5911
|
+
}
|
|
5912
|
+
}
|
|
5913
|
+
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5914
|
+
vnode.elm = node;
|
|
5915
|
+
return node;
|
|
5916
|
+
}
|
|
5917
|
+
function hydrateElement(elm, vnode) {
|
|
5918
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
|
|
5919
|
+
!isMatchingElement(vnode, elm)) {
|
|
5920
|
+
return handleMismatch(elm, vnode);
|
|
5921
|
+
}
|
|
5922
|
+
vnode.elm = elm;
|
|
5923
|
+
const { context } = vnode.data;
|
|
5924
|
+
const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
5925
|
+
if (isDomManual) {
|
|
5926
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5927
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5928
|
+
const { props } = vnode.data;
|
|
5929
|
+
if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
|
|
5930
|
+
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5931
|
+
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
5932
|
+
vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
|
|
5933
|
+
}
|
|
5934
|
+
else {
|
|
5935
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5936
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
5937
|
+
}
|
|
5938
|
+
}
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5941
|
+
patchElementPropsAndAttrs(vnode);
|
|
5942
|
+
if (!isDomManual) {
|
|
5943
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vnode.owner);
|
|
5944
|
+
}
|
|
5945
|
+
return elm;
|
|
5946
|
+
}
|
|
5947
|
+
function hydrateCustomElement(elm, vnode) {
|
|
5948
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
|
|
5949
|
+
!isMatchingElement(vnode, elm)) {
|
|
5950
|
+
return handleMismatch(elm, vnode);
|
|
5951
|
+
}
|
|
5952
|
+
const { sel, mode, ctor, owner } = vnode;
|
|
5953
|
+
const vm = createVM(elm, ctor, {
|
|
5954
|
+
mode,
|
|
5955
|
+
owner,
|
|
5956
|
+
tagName: sel,
|
|
5957
|
+
});
|
|
5958
|
+
vnode.elm = elm;
|
|
5959
|
+
vnode.vm = vm;
|
|
5960
|
+
allocateChildren(vnode, vm);
|
|
5961
|
+
patchElementPropsAndAttrs(vnode);
|
|
5962
|
+
// Insert hook section:
|
|
5963
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5964
|
+
shared.assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
5965
|
+
}
|
|
5966
|
+
runConnectedCallback(vm);
|
|
5967
|
+
if (vm.renderMode !== 0 /* Light */) {
|
|
5968
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5969
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5970
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
5971
|
+
}
|
|
5972
|
+
hydrateVM(vm);
|
|
5973
|
+
return elm;
|
|
5974
|
+
}
|
|
5975
|
+
function hydrateChildren(node, children, parentNode, owner) {
|
|
5976
|
+
let hasWarned = false;
|
|
5977
|
+
let nextNode = node;
|
|
5978
|
+
let anchor = null;
|
|
5979
|
+
for (let i = 0; i < children.length; i++) {
|
|
5980
|
+
const childVnode = children[i];
|
|
5981
|
+
if (!shared.isNull(childVnode)) {
|
|
5982
|
+
if (nextNode) {
|
|
5983
|
+
nextNode = hydrateNode(nextNode, childVnode);
|
|
5984
|
+
anchor = childVnode.elm;
|
|
5985
|
+
}
|
|
5986
|
+
else {
|
|
5987
|
+
hasMismatch = true;
|
|
5988
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5989
|
+
if (!hasWarned) {
|
|
5990
|
+
hasWarned = true;
|
|
5991
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
5992
|
+
}
|
|
5993
|
+
}
|
|
5994
|
+
mount(childVnode, parentNode, anchor);
|
|
5995
|
+
anchor = childVnode.elm;
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
if (nextNode) {
|
|
6000
|
+
hasMismatch = true;
|
|
6001
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6002
|
+
if (!hasWarned) {
|
|
6003
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
6004
|
+
}
|
|
6005
|
+
}
|
|
6006
|
+
do {
|
|
6007
|
+
const current = nextNode;
|
|
6008
|
+
nextNode = nextSibling(nextNode);
|
|
6009
|
+
removeNode(current, parentNode);
|
|
6010
|
+
} while (nextNode);
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
function handleMismatch(node, vnode, msg) {
|
|
6014
|
+
hasMismatch = true;
|
|
6015
|
+
if (!shared.isUndefined(msg)) {
|
|
6016
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6017
|
+
logError(msg, vnode.owner);
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
const parentNode = getProperty(node, 'parentNode');
|
|
6021
|
+
mount(vnode, parentNode, node);
|
|
6022
|
+
removeNode(node, parentNode);
|
|
6023
|
+
return vnode.elm;
|
|
6024
|
+
}
|
|
6025
|
+
function patchElementPropsAndAttrs(vnode) {
|
|
6026
|
+
applyEventListeners(vnode);
|
|
6027
|
+
patchProps(null, vnode);
|
|
6028
|
+
}
|
|
6029
|
+
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
6030
|
+
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6031
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6032
|
+
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6033
|
+
}
|
|
6034
|
+
return false;
|
|
6035
|
+
}
|
|
6036
|
+
return true;
|
|
6037
|
+
}
|
|
6038
|
+
function isMatchingElement(vnode, elm) {
|
|
6039
|
+
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6040
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6041
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6042
|
+
}
|
|
6043
|
+
return false;
|
|
6044
|
+
}
|
|
6045
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6046
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6047
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
6048
|
+
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6049
|
+
}
|
|
6050
|
+
function validateAttrs(vnode, elm) {
|
|
6051
|
+
const { data: { attrs = {} }, } = vnode;
|
|
6052
|
+
let nodesAreCompatible = true;
|
|
6053
|
+
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6054
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6055
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
6056
|
+
const elmAttrValue = getAttribute(elm, attrName);
|
|
6057
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
6058
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6059
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6060
|
+
}
|
|
6061
|
+
nodesAreCompatible = false;
|
|
6062
|
+
}
|
|
6063
|
+
}
|
|
6064
|
+
return nodesAreCompatible;
|
|
6065
|
+
}
|
|
6066
|
+
function validateClassAttr(vnode, elm) {
|
|
6067
|
+
const { data: { className, classMap }, } = vnode;
|
|
6068
|
+
let nodesAreCompatible = true;
|
|
6069
|
+
let vnodeClassName;
|
|
6070
|
+
if (!shared.isUndefined(className) && String(className) !== getProperty(elm, 'className')) {
|
|
6071
|
+
// className is used when class is bound to an expr.
|
|
6072
|
+
nodesAreCompatible = false;
|
|
6073
|
+
vnodeClassName = className;
|
|
6074
|
+
}
|
|
6075
|
+
else if (!shared.isUndefined(classMap)) {
|
|
6076
|
+
// classMap is used when class is set to static value.
|
|
6077
|
+
const classList = getClassList(elm);
|
|
6078
|
+
let computedClassName = '';
|
|
6079
|
+
// all classes from the vnode should be in the element.classList
|
|
6080
|
+
for (const name in classMap) {
|
|
6081
|
+
computedClassName += ' ' + name;
|
|
6082
|
+
if (!classList.contains(name)) {
|
|
6083
|
+
nodesAreCompatible = false;
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
vnodeClassName = computedClassName.trim();
|
|
6087
|
+
if (classList.length > shared.keys(classMap).length) {
|
|
6088
|
+
nodesAreCompatible = false;
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
if (!nodesAreCompatible) {
|
|
6092
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6093
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
|
|
6094
|
+
}
|
|
6095
|
+
}
|
|
6096
|
+
return nodesAreCompatible;
|
|
6097
|
+
}
|
|
6098
|
+
function validateStyleAttr(vnode, elm) {
|
|
6099
|
+
const { data: { style, styleDecls }, } = vnode;
|
|
6100
|
+
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6101
|
+
let vnodeStyle;
|
|
6102
|
+
let nodesAreCompatible = true;
|
|
6103
|
+
if (!shared.isUndefined(style) && style !== elmStyle) {
|
|
6104
|
+
nodesAreCompatible = false;
|
|
6105
|
+
vnodeStyle = style;
|
|
6106
|
+
}
|
|
6107
|
+
else if (!shared.isUndefined(styleDecls)) {
|
|
6108
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
6109
|
+
const expectedStyle = [];
|
|
6110
|
+
// styleMap is used when style is set to static value.
|
|
6111
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
6112
|
+
const [prop, value, important] = styleDecls[i];
|
|
6113
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
6114
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
6115
|
+
if (shared.isUndefined(parsedPropValue)) {
|
|
6116
|
+
nodesAreCompatible = false;
|
|
6117
|
+
}
|
|
6118
|
+
else if (!parsedPropValue.startsWith(value)) {
|
|
6119
|
+
nodesAreCompatible = false;
|
|
6120
|
+
}
|
|
6121
|
+
else if (important && !parsedPropValue.endsWith('!important')) {
|
|
6122
|
+
nodesAreCompatible = false;
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
6126
|
+
nodesAreCompatible = false;
|
|
6127
|
+
}
|
|
6128
|
+
vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
|
|
6129
|
+
}
|
|
6130
|
+
if (!nodesAreCompatible) {
|
|
6131
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6132
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
return nodesAreCompatible;
|
|
6136
|
+
}
|
|
6137
|
+
|
|
6067
6138
|
/*
|
|
6068
6139
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6069
6140
|
* All rights reserved.
|
|
@@ -6096,7 +6167,7 @@ exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
|
|
|
6096
6167
|
exports.getComponentDef = getComponentDef;
|
|
6097
6168
|
exports.getComponentHtmlPrototype = getComponentHtmlPrototype;
|
|
6098
6169
|
exports.getUpgradableConstructor = getUpgradableConstructor;
|
|
6099
|
-
exports.
|
|
6170
|
+
exports.hydrateRoot = hydrateRoot;
|
|
6100
6171
|
exports.isComponentConstructor = isComponentConstructor;
|
|
6101
6172
|
exports.readonly = readonly;
|
|
6102
6173
|
exports.register = register;
|
|
@@ -6151,4 +6222,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6151
6222
|
exports.track = track;
|
|
6152
6223
|
exports.unwrap = unwrap;
|
|
6153
6224
|
exports.wire = wire;
|
|
6154
|
-
/* version: 2.11.
|
|
6225
|
+
/* version: 2.11.5 */
|
package/dist/engine-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
|
-
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift
|
|
2
|
+
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift } from '@lwc/shared';
|
|
3
3
|
import { runtimeFlags } from '@lwc/features';
|
|
4
4
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
5
5
|
|
|
@@ -2304,6 +2304,12 @@ function checkVersionMismatch(func, type) {
|
|
|
2304
2304
|
}
|
|
2305
2305
|
}
|
|
2306
2306
|
|
|
2307
|
+
/*
|
|
2308
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2309
|
+
* All rights reserved.
|
|
2310
|
+
* SPDX-License-Identifier: MIT
|
|
2311
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2312
|
+
*/
|
|
2307
2313
|
const signedTemplateSet = new Set();
|
|
2308
2314
|
function defaultEmptyTemplate() {
|
|
2309
2315
|
return [];
|
|
@@ -2321,6 +2327,30 @@ function registerTemplate(tpl) {
|
|
|
2321
2327
|
checkVersionMismatch(tpl, 'template');
|
|
2322
2328
|
}
|
|
2323
2329
|
signedTemplateSet.add(tpl);
|
|
2330
|
+
// FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
|
|
2331
|
+
// the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
|
|
2332
|
+
// on top of stylesheetToken for anyone who is accessing the old internal API.
|
|
2333
|
+
// Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
2334
|
+
defineProperty(tpl, 'stylesheetTokens', {
|
|
2335
|
+
get() {
|
|
2336
|
+
const { stylesheetToken } = this;
|
|
2337
|
+
if (isUndefined$1(stylesheetToken)) {
|
|
2338
|
+
return stylesheetToken;
|
|
2339
|
+
}
|
|
2340
|
+
// Shim for the old `stylesheetTokens` property
|
|
2341
|
+
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
2342
|
+
return {
|
|
2343
|
+
hostAttribute: `${stylesheetToken}-host`,
|
|
2344
|
+
shadowAttribute: stylesheetToken,
|
|
2345
|
+
};
|
|
2346
|
+
},
|
|
2347
|
+
set(value) {
|
|
2348
|
+
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
2349
|
+
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
2350
|
+
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
2351
|
+
this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
|
|
2352
|
+
},
|
|
2353
|
+
});
|
|
2324
2354
|
// chaining this method as a way to wrap existing
|
|
2325
2355
|
// assignment of templates easily, without too much transformation
|
|
2326
2356
|
return tpl;
|
|
@@ -4799,236 +4829,6 @@ function invokeServiceHook(vm, cbs) {
|
|
|
4799
4829
|
}
|
|
4800
4830
|
}
|
|
4801
4831
|
|
|
4802
|
-
/*
|
|
4803
|
-
* Copyright (c) 2022, salesforce.com, inc.
|
|
4804
|
-
* All rights reserved.
|
|
4805
|
-
* SPDX-License-Identifier: MIT
|
|
4806
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4807
|
-
*/
|
|
4808
|
-
function hydrate(vnode, node) {
|
|
4809
|
-
switch (vnode.type) {
|
|
4810
|
-
case 0 /* Text */:
|
|
4811
|
-
hydrateText(vnode, node);
|
|
4812
|
-
break;
|
|
4813
|
-
case 1 /* Comment */:
|
|
4814
|
-
hydrateComment(vnode, node);
|
|
4815
|
-
break;
|
|
4816
|
-
case 2 /* Element */:
|
|
4817
|
-
hydrateElement(vnode, node);
|
|
4818
|
-
break;
|
|
4819
|
-
case 3 /* CustomElement */:
|
|
4820
|
-
hydrateCustomElement(vnode, node);
|
|
4821
|
-
break;
|
|
4822
|
-
}
|
|
4823
|
-
}
|
|
4824
|
-
function hydrateText(vnode, node) {
|
|
4825
|
-
var _a;
|
|
4826
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4827
|
-
validateNodeType(vnode, node, 3 /* TEXT */);
|
|
4828
|
-
const nodeValue = getProperty(node, 'nodeValue');
|
|
4829
|
-
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
4830
|
-
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
4831
|
-
}
|
|
4832
|
-
}
|
|
4833
|
-
// always set the text value to the one from the vnode.
|
|
4834
|
-
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4835
|
-
vnode.elm = node;
|
|
4836
|
-
}
|
|
4837
|
-
function hydrateComment(vnode, node) {
|
|
4838
|
-
var _a;
|
|
4839
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4840
|
-
validateNodeType(vnode, node, 8 /* COMMENT */);
|
|
4841
|
-
if (getProperty(node, 'nodeValue') !== vnode.text) {
|
|
4842
|
-
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
4843
|
-
}
|
|
4844
|
-
}
|
|
4845
|
-
// always set the text value to the one from the vnode.
|
|
4846
|
-
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4847
|
-
vnode.elm = node;
|
|
4848
|
-
}
|
|
4849
|
-
function hydrateElement(vnode, node) {
|
|
4850
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4851
|
-
validateNodeType(vnode, node, 1 /* ELEMENT */);
|
|
4852
|
-
validateElement(vnode, node);
|
|
4853
|
-
}
|
|
4854
|
-
const elm = node;
|
|
4855
|
-
vnode.elm = elm;
|
|
4856
|
-
const { context } = vnode.data;
|
|
4857
|
-
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
4858
|
-
if (isDomManual) {
|
|
4859
|
-
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
4860
|
-
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
4861
|
-
const { props } = vnode.data;
|
|
4862
|
-
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
4863
|
-
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
4864
|
-
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
4865
|
-
vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
|
|
4866
|
-
}
|
|
4867
|
-
else {
|
|
4868
|
-
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
4869
|
-
}
|
|
4870
|
-
}
|
|
4871
|
-
}
|
|
4872
|
-
patchElementPropsAndAttrs(vnode);
|
|
4873
|
-
if (!isDomManual) {
|
|
4874
|
-
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vnode.owner);
|
|
4875
|
-
}
|
|
4876
|
-
}
|
|
4877
|
-
function hydrateCustomElement(vnode, node) {
|
|
4878
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4879
|
-
validateNodeType(vnode, node, 1 /* ELEMENT */);
|
|
4880
|
-
validateElement(vnode, node);
|
|
4881
|
-
}
|
|
4882
|
-
const elm = node;
|
|
4883
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
4884
|
-
const vm = createVM(elm, ctor, {
|
|
4885
|
-
mode,
|
|
4886
|
-
owner,
|
|
4887
|
-
tagName: sel,
|
|
4888
|
-
});
|
|
4889
|
-
vnode.elm = elm;
|
|
4890
|
-
vnode.vm = vm;
|
|
4891
|
-
allocateChildren(vnode, vm);
|
|
4892
|
-
patchElementPropsAndAttrs(vnode);
|
|
4893
|
-
// Insert hook section:
|
|
4894
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4895
|
-
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
4896
|
-
}
|
|
4897
|
-
runConnectedCallback(vm);
|
|
4898
|
-
if (vm.renderMode !== 0 /* Light */) {
|
|
4899
|
-
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
4900
|
-
// Note: for Light DOM, this is handled while hydrating the VM
|
|
4901
|
-
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vm);
|
|
4902
|
-
}
|
|
4903
|
-
hydrateVM(vm);
|
|
4904
|
-
}
|
|
4905
|
-
function hydrateChildren(elmChildren, children, vm) {
|
|
4906
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4907
|
-
const filteredVNodes = ArrayFilter.call(children, (vnode) => !!vnode);
|
|
4908
|
-
if (elmChildren.length !== filteredVNodes.length) {
|
|
4909
|
-
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4910
|
-
throwHydrationError();
|
|
4911
|
-
}
|
|
4912
|
-
}
|
|
4913
|
-
let childNodeIndex = 0;
|
|
4914
|
-
for (let i = 0; i < children.length; i++) {
|
|
4915
|
-
const childVnode = children[i];
|
|
4916
|
-
if (!isNull(childVnode)) {
|
|
4917
|
-
const childNode = elmChildren[childNodeIndex];
|
|
4918
|
-
hydrate(childVnode, childNode);
|
|
4919
|
-
childNodeIndex++;
|
|
4920
|
-
}
|
|
4921
|
-
}
|
|
4922
|
-
}
|
|
4923
|
-
function patchElementPropsAndAttrs(vnode) {
|
|
4924
|
-
applyEventListeners(vnode);
|
|
4925
|
-
patchProps(null, vnode);
|
|
4926
|
-
}
|
|
4927
|
-
function throwHydrationError() {
|
|
4928
|
-
assert.fail('Server rendered elements do not match client side generated elements');
|
|
4929
|
-
}
|
|
4930
|
-
function validateNodeType(vnode, node, nodeType) {
|
|
4931
|
-
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
4932
|
-
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
4933
|
-
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
4934
|
-
}
|
|
4935
|
-
}
|
|
4936
|
-
function validateElement(vnode, elm) {
|
|
4937
|
-
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
4938
|
-
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
4939
|
-
throwHydrationError();
|
|
4940
|
-
}
|
|
4941
|
-
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
4942
|
-
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
4943
|
-
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
4944
|
-
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
4945
|
-
if (!isVNodeAndElementCompatible) {
|
|
4946
|
-
throwHydrationError();
|
|
4947
|
-
}
|
|
4948
|
-
}
|
|
4949
|
-
function validateAttrs(vnode, elm) {
|
|
4950
|
-
const { data: { attrs = {} }, } = vnode;
|
|
4951
|
-
let nodesAreCompatible = true;
|
|
4952
|
-
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
4953
|
-
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4954
|
-
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4955
|
-
const elmAttrValue = getAttribute(elm, attrName);
|
|
4956
|
-
if (String(attrValue) !== elmAttrValue) {
|
|
4957
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4958
|
-
nodesAreCompatible = false;
|
|
4959
|
-
}
|
|
4960
|
-
}
|
|
4961
|
-
return nodesAreCompatible;
|
|
4962
|
-
}
|
|
4963
|
-
function validateClassAttr(vnode, elm) {
|
|
4964
|
-
const { data: { className, classMap }, } = vnode;
|
|
4965
|
-
let nodesAreCompatible = true;
|
|
4966
|
-
let vnodeClassName;
|
|
4967
|
-
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
4968
|
-
// className is used when class is bound to an expr.
|
|
4969
|
-
nodesAreCompatible = false;
|
|
4970
|
-
vnodeClassName = className;
|
|
4971
|
-
}
|
|
4972
|
-
else if (!isUndefined$1(classMap)) {
|
|
4973
|
-
// classMap is used when class is set to static value.
|
|
4974
|
-
const classList = getClassList(elm);
|
|
4975
|
-
let computedClassName = '';
|
|
4976
|
-
// all classes from the vnode should be in the element.classList
|
|
4977
|
-
for (const name in classMap) {
|
|
4978
|
-
computedClassName += ' ' + name;
|
|
4979
|
-
if (!classList.contains(name)) {
|
|
4980
|
-
nodesAreCompatible = false;
|
|
4981
|
-
}
|
|
4982
|
-
}
|
|
4983
|
-
vnodeClassName = computedClassName.trim();
|
|
4984
|
-
if (classList.length > keys(classMap).length) {
|
|
4985
|
-
nodesAreCompatible = false;
|
|
4986
|
-
}
|
|
4987
|
-
}
|
|
4988
|
-
if (!nodesAreCompatible) {
|
|
4989
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
|
|
4990
|
-
}
|
|
4991
|
-
return nodesAreCompatible;
|
|
4992
|
-
}
|
|
4993
|
-
function validateStyleAttr(vnode, elm) {
|
|
4994
|
-
const { data: { style, styleDecls }, } = vnode;
|
|
4995
|
-
const elmStyle = getAttribute(elm, 'style') || '';
|
|
4996
|
-
let vnodeStyle;
|
|
4997
|
-
let nodesAreCompatible = true;
|
|
4998
|
-
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
4999
|
-
nodesAreCompatible = false;
|
|
5000
|
-
vnodeStyle = style;
|
|
5001
|
-
}
|
|
5002
|
-
else if (!isUndefined$1(styleDecls)) {
|
|
5003
|
-
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
5004
|
-
const expectedStyle = [];
|
|
5005
|
-
// styleMap is used when style is set to static value.
|
|
5006
|
-
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
5007
|
-
const [prop, value, important] = styleDecls[i];
|
|
5008
|
-
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
5009
|
-
const parsedPropValue = parsedVnodeStyle[prop];
|
|
5010
|
-
if (isUndefined$1(parsedPropValue)) {
|
|
5011
|
-
nodesAreCompatible = false;
|
|
5012
|
-
}
|
|
5013
|
-
else if (!parsedPropValue.startsWith(value)) {
|
|
5014
|
-
nodesAreCompatible = false;
|
|
5015
|
-
}
|
|
5016
|
-
else if (important && !parsedPropValue.endsWith('!important')) {
|
|
5017
|
-
nodesAreCompatible = false;
|
|
5018
|
-
}
|
|
5019
|
-
}
|
|
5020
|
-
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
5021
|
-
nodesAreCompatible = false;
|
|
5022
|
-
}
|
|
5023
|
-
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
5024
|
-
}
|
|
5025
|
-
if (!nodesAreCompatible) {
|
|
5026
|
-
// style is used when class is bound to an expr.
|
|
5027
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
5028
|
-
}
|
|
5029
|
-
return nodesAreCompatible;
|
|
5030
|
-
}
|
|
5031
|
-
|
|
5032
4832
|
/*
|
|
5033
4833
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5034
4834
|
* All rights reserved.
|
|
@@ -5074,32 +4874,12 @@ function connectRootElement(elm) {
|
|
|
5074
4874
|
/* GlobalHydrate */
|
|
5075
4875
|
, vm);
|
|
5076
4876
|
}
|
|
5077
|
-
function hydrateRootElement(elm) {
|
|
5078
|
-
const vm = getAssociatedVM(elm);
|
|
5079
|
-
runConnectedCallback(vm);
|
|
5080
|
-
hydrateVM(vm);
|
|
5081
|
-
}
|
|
5082
4877
|
function disconnectRootElement(elm) {
|
|
5083
4878
|
const vm = getAssociatedVM(elm);
|
|
5084
4879
|
resetComponentStateWhenRemoved(vm);
|
|
5085
4880
|
}
|
|
5086
4881
|
function appendVM(vm) {
|
|
5087
4882
|
rehydrate(vm);
|
|
5088
|
-
}
|
|
5089
|
-
function hydrateVM(vm) {
|
|
5090
|
-
if (isTrue(vm.isDirty)) {
|
|
5091
|
-
// manually diffing/patching here.
|
|
5092
|
-
// This routine is:
|
|
5093
|
-
// patchShadowRoot(vm, children);
|
|
5094
|
-
// -> addVnodes.
|
|
5095
|
-
const children = renderComponent(vm);
|
|
5096
|
-
vm.children = children;
|
|
5097
|
-
const vmChildren = vm.renderMode === 0
|
|
5098
|
-
/* Light */
|
|
5099
|
-
? getChildNodes(vm.elm) : getChildNodes(vm.elm.shadowRoot);
|
|
5100
|
-
hydrateChildren(vmChildren, children, vm);
|
|
5101
|
-
runRenderedCallback(vm);
|
|
5102
|
-
}
|
|
5103
4883
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
5104
4884
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5105
4885
|
|
|
@@ -5404,7 +5184,6 @@ function runRenderedCallback(vm) {
|
|
|
5404
5184
|
, vm);
|
|
5405
5185
|
}
|
|
5406
5186
|
}
|
|
5407
|
-
|
|
5408
5187
|
let rehydrateQueue = [];
|
|
5409
5188
|
|
|
5410
5189
|
function flushRehydrationQueue() {
|
|
@@ -6061,6 +5840,298 @@ function readonly(obj) {
|
|
|
6061
5840
|
return reactiveMembrane.getReadOnlyProxy(obj);
|
|
6062
5841
|
}
|
|
6063
5842
|
|
|
5843
|
+
/*
|
|
5844
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
5845
|
+
* All rights reserved.
|
|
5846
|
+
* SPDX-License-Identifier: MIT
|
|
5847
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5848
|
+
*/
|
|
5849
|
+
// flag indicating if the hydration recovered from the DOM mismatch
|
|
5850
|
+
let hasMismatch = false;
|
|
5851
|
+
function hydrateRoot(vm) {
|
|
5852
|
+
hasMismatch = false;
|
|
5853
|
+
runConnectedCallback(vm);
|
|
5854
|
+
hydrateVM(vm);
|
|
5855
|
+
if (hasMismatch) {
|
|
5856
|
+
logError('Hydration completed with errors.', vm);
|
|
5857
|
+
}
|
|
5858
|
+
}
|
|
5859
|
+
function hydrateVM(vm) {
|
|
5860
|
+
const children = renderComponent(vm);
|
|
5861
|
+
vm.children = children;
|
|
5862
|
+
const parentNode = vm.renderRoot;
|
|
5863
|
+
hydrateChildren(getFirstChild(parentNode), children, parentNode, vm);
|
|
5864
|
+
runRenderedCallback(vm);
|
|
5865
|
+
}
|
|
5866
|
+
function hydrateNode(node, vnode) {
|
|
5867
|
+
let hydratedNode;
|
|
5868
|
+
switch (vnode.type) {
|
|
5869
|
+
case 0 /* Text */:
|
|
5870
|
+
hydratedNode = hydrateText(node, vnode);
|
|
5871
|
+
break;
|
|
5872
|
+
case 1 /* Comment */:
|
|
5873
|
+
hydratedNode = hydrateComment(node, vnode);
|
|
5874
|
+
break;
|
|
5875
|
+
case 2 /* Element */:
|
|
5876
|
+
hydratedNode = hydrateElement(node, vnode);
|
|
5877
|
+
break;
|
|
5878
|
+
case 3 /* CustomElement */:
|
|
5879
|
+
hydratedNode = hydrateCustomElement(node, vnode);
|
|
5880
|
+
break;
|
|
5881
|
+
}
|
|
5882
|
+
return nextSibling(hydratedNode);
|
|
5883
|
+
}
|
|
5884
|
+
function hydrateText(node, vnode) {
|
|
5885
|
+
var _a;
|
|
5886
|
+
if (!hasCorrectNodeType(vnode, node, 3 /* TEXT */)) {
|
|
5887
|
+
return handleMismatch(node, vnode);
|
|
5888
|
+
}
|
|
5889
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5890
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
5891
|
+
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5892
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5893
|
+
}
|
|
5894
|
+
}
|
|
5895
|
+
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5896
|
+
vnode.elm = node;
|
|
5897
|
+
return node;
|
|
5898
|
+
}
|
|
5899
|
+
function hydrateComment(node, vnode) {
|
|
5900
|
+
var _a;
|
|
5901
|
+
if (!hasCorrectNodeType(vnode, node, 8 /* COMMENT */)) {
|
|
5902
|
+
return handleMismatch(node, vnode);
|
|
5903
|
+
}
|
|
5904
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5905
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
5906
|
+
if (nodeValue !== vnode.text) {
|
|
5907
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5908
|
+
}
|
|
5909
|
+
}
|
|
5910
|
+
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5911
|
+
vnode.elm = node;
|
|
5912
|
+
return node;
|
|
5913
|
+
}
|
|
5914
|
+
function hydrateElement(elm, vnode) {
|
|
5915
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
|
|
5916
|
+
!isMatchingElement(vnode, elm)) {
|
|
5917
|
+
return handleMismatch(elm, vnode);
|
|
5918
|
+
}
|
|
5919
|
+
vnode.elm = elm;
|
|
5920
|
+
const { context } = vnode.data;
|
|
5921
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual" /* Manual */);
|
|
5922
|
+
if (isDomManual) {
|
|
5923
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5924
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5925
|
+
const { props } = vnode.data;
|
|
5926
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5927
|
+
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5928
|
+
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
5929
|
+
vnode.data = Object.assign(Object.assign({}, vnode.data), { props: cloneAndOmitKey(props, 'innerHTML') });
|
|
5930
|
+
}
|
|
5931
|
+
else {
|
|
5932
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5933
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
patchElementPropsAndAttrs(vnode);
|
|
5939
|
+
if (!isDomManual) {
|
|
5940
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vnode.owner);
|
|
5941
|
+
}
|
|
5942
|
+
return elm;
|
|
5943
|
+
}
|
|
5944
|
+
function hydrateCustomElement(elm, vnode) {
|
|
5945
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* ELEMENT */) ||
|
|
5946
|
+
!isMatchingElement(vnode, elm)) {
|
|
5947
|
+
return handleMismatch(elm, vnode);
|
|
5948
|
+
}
|
|
5949
|
+
const { sel, mode, ctor, owner } = vnode;
|
|
5950
|
+
const vm = createVM(elm, ctor, {
|
|
5951
|
+
mode,
|
|
5952
|
+
owner,
|
|
5953
|
+
tagName: sel,
|
|
5954
|
+
});
|
|
5955
|
+
vnode.elm = elm;
|
|
5956
|
+
vnode.vm = vm;
|
|
5957
|
+
allocateChildren(vnode, vm);
|
|
5958
|
+
patchElementPropsAndAttrs(vnode);
|
|
5959
|
+
// Insert hook section:
|
|
5960
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5961
|
+
assert.isTrue(vm.state === 0 /* created */, `${vm} cannot be recycled.`);
|
|
5962
|
+
}
|
|
5963
|
+
runConnectedCallback(vm);
|
|
5964
|
+
if (vm.renderMode !== 0 /* Light */) {
|
|
5965
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5966
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5967
|
+
hydrateChildren(getFirstChild(elm), vnode.children, elm, vm);
|
|
5968
|
+
}
|
|
5969
|
+
hydrateVM(vm);
|
|
5970
|
+
return elm;
|
|
5971
|
+
}
|
|
5972
|
+
function hydrateChildren(node, children, parentNode, owner) {
|
|
5973
|
+
let hasWarned = false;
|
|
5974
|
+
let nextNode = node;
|
|
5975
|
+
let anchor = null;
|
|
5976
|
+
for (let i = 0; i < children.length; i++) {
|
|
5977
|
+
const childVnode = children[i];
|
|
5978
|
+
if (!isNull(childVnode)) {
|
|
5979
|
+
if (nextNode) {
|
|
5980
|
+
nextNode = hydrateNode(nextNode, childVnode);
|
|
5981
|
+
anchor = childVnode.elm;
|
|
5982
|
+
}
|
|
5983
|
+
else {
|
|
5984
|
+
hasMismatch = true;
|
|
5985
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5986
|
+
if (!hasWarned) {
|
|
5987
|
+
hasWarned = true;
|
|
5988
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5991
|
+
mount(childVnode, parentNode, anchor);
|
|
5992
|
+
anchor = childVnode.elm;
|
|
5993
|
+
}
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
if (nextNode) {
|
|
5997
|
+
hasMismatch = true;
|
|
5998
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5999
|
+
if (!hasWarned) {
|
|
6000
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
6003
|
+
do {
|
|
6004
|
+
const current = nextNode;
|
|
6005
|
+
nextNode = nextSibling(nextNode);
|
|
6006
|
+
removeNode(current, parentNode);
|
|
6007
|
+
} while (nextNode);
|
|
6008
|
+
}
|
|
6009
|
+
}
|
|
6010
|
+
function handleMismatch(node, vnode, msg) {
|
|
6011
|
+
hasMismatch = true;
|
|
6012
|
+
if (!isUndefined$1(msg)) {
|
|
6013
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6014
|
+
logError(msg, vnode.owner);
|
|
6015
|
+
}
|
|
6016
|
+
}
|
|
6017
|
+
const parentNode = getProperty(node, 'parentNode');
|
|
6018
|
+
mount(vnode, parentNode, node);
|
|
6019
|
+
removeNode(node, parentNode);
|
|
6020
|
+
return vnode.elm;
|
|
6021
|
+
}
|
|
6022
|
+
function patchElementPropsAndAttrs(vnode) {
|
|
6023
|
+
applyEventListeners(vnode);
|
|
6024
|
+
patchProps(null, vnode);
|
|
6025
|
+
}
|
|
6026
|
+
function hasCorrectNodeType(vnode, node, nodeType) {
|
|
6027
|
+
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6028
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6029
|
+
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6030
|
+
}
|
|
6031
|
+
return false;
|
|
6032
|
+
}
|
|
6033
|
+
return true;
|
|
6034
|
+
}
|
|
6035
|
+
function isMatchingElement(vnode, elm) {
|
|
6036
|
+
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6037
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6038
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6039
|
+
}
|
|
6040
|
+
return false;
|
|
6041
|
+
}
|
|
6042
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6043
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6044
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
6045
|
+
return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6046
|
+
}
|
|
6047
|
+
function validateAttrs(vnode, elm) {
|
|
6048
|
+
const { data: { attrs = {} }, } = vnode;
|
|
6049
|
+
let nodesAreCompatible = true;
|
|
6050
|
+
// Validate attributes, though we could always recovery from those by running the update mods.
|
|
6051
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6052
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
6053
|
+
const elmAttrValue = getAttribute(elm, attrName);
|
|
6054
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
6055
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6056
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6057
|
+
}
|
|
6058
|
+
nodesAreCompatible = false;
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
return nodesAreCompatible;
|
|
6062
|
+
}
|
|
6063
|
+
function validateClassAttr(vnode, elm) {
|
|
6064
|
+
const { data: { className, classMap }, } = vnode;
|
|
6065
|
+
let nodesAreCompatible = true;
|
|
6066
|
+
let vnodeClassName;
|
|
6067
|
+
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
6068
|
+
// className is used when class is bound to an expr.
|
|
6069
|
+
nodesAreCompatible = false;
|
|
6070
|
+
vnodeClassName = className;
|
|
6071
|
+
}
|
|
6072
|
+
else if (!isUndefined$1(classMap)) {
|
|
6073
|
+
// classMap is used when class is set to static value.
|
|
6074
|
+
const classList = getClassList(elm);
|
|
6075
|
+
let computedClassName = '';
|
|
6076
|
+
// all classes from the vnode should be in the element.classList
|
|
6077
|
+
for (const name in classMap) {
|
|
6078
|
+
computedClassName += ' ' + name;
|
|
6079
|
+
if (!classList.contains(name)) {
|
|
6080
|
+
nodesAreCompatible = false;
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
vnodeClassName = computedClassName.trim();
|
|
6084
|
+
if (classList.length > keys(classMap).length) {
|
|
6085
|
+
nodesAreCompatible = false;
|
|
6086
|
+
}
|
|
6087
|
+
}
|
|
6088
|
+
if (!nodesAreCompatible) {
|
|
6089
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6090
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
return nodesAreCompatible;
|
|
6094
|
+
}
|
|
6095
|
+
function validateStyleAttr(vnode, elm) {
|
|
6096
|
+
const { data: { style, styleDecls }, } = vnode;
|
|
6097
|
+
const elmStyle = getAttribute(elm, 'style') || '';
|
|
6098
|
+
let vnodeStyle;
|
|
6099
|
+
let nodesAreCompatible = true;
|
|
6100
|
+
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
6101
|
+
nodesAreCompatible = false;
|
|
6102
|
+
vnodeStyle = style;
|
|
6103
|
+
}
|
|
6104
|
+
else if (!isUndefined$1(styleDecls)) {
|
|
6105
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
6106
|
+
const expectedStyle = [];
|
|
6107
|
+
// styleMap is used when style is set to static value.
|
|
6108
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
6109
|
+
const [prop, value, important] = styleDecls[i];
|
|
6110
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
6111
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
6112
|
+
if (isUndefined$1(parsedPropValue)) {
|
|
6113
|
+
nodesAreCompatible = false;
|
|
6114
|
+
}
|
|
6115
|
+
else if (!parsedPropValue.startsWith(value)) {
|
|
6116
|
+
nodesAreCompatible = false;
|
|
6117
|
+
}
|
|
6118
|
+
else if (important && !parsedPropValue.endsWith('!important')) {
|
|
6119
|
+
nodesAreCompatible = false;
|
|
6120
|
+
}
|
|
6121
|
+
}
|
|
6122
|
+
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
6123
|
+
nodesAreCompatible = false;
|
|
6124
|
+
}
|
|
6125
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
6126
|
+
}
|
|
6127
|
+
if (!nodesAreCompatible) {
|
|
6128
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6129
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
return nodesAreCompatible;
|
|
6133
|
+
}
|
|
6134
|
+
|
|
6064
6135
|
/*
|
|
6065
6136
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6066
6137
|
* All rights reserved.
|
|
@@ -6074,5 +6145,5 @@ function setHooks(hooks) {
|
|
|
6074
6145
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
6075
6146
|
}
|
|
6076
6147
|
|
|
6077
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor,
|
|
6078
|
-
/* version: 2.11.
|
|
6148
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6149
|
+
/* version: 2.11.5 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/engine-core",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.5",
|
|
4
4
|
"description": "Core LWC engine APIs.",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
"types/"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lwc/features": "2.11.
|
|
28
|
-
"@lwc/shared": "2.11.
|
|
27
|
+
"@lwc/features": "2.11.5",
|
|
28
|
+
"@lwc/shared": "2.11.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"observable-membrane": "2.0.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
|
-
}
|
|
36
|
-
"gitHead": "94040389ab8fc717b8753e503f659489480a327d"
|
|
35
|
+
}
|
|
37
36
|
}
|
|
@@ -7,7 +7,8 @@ export { default as wire } from './decorators/wire';
|
|
|
7
7
|
export { readonly } from './readonly';
|
|
8
8
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
9
9
|
export { getComponentHtmlPrototype } from './def';
|
|
10
|
-
export { createVM, connectRootElement, disconnectRootElement, getAssociatedVMIfPresent,
|
|
10
|
+
export { createVM, connectRootElement, disconnectRootElement, getAssociatedVMIfPresent, } from './vm';
|
|
11
|
+
export { hydrateRoot } from './hydration';
|
|
11
12
|
export { registerComponent } from './component';
|
|
12
13
|
export { registerTemplate } from './secure-template';
|
|
13
14
|
export { registerDecorators } from './decorators/register';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { VM } from './vm';
|
|
2
|
-
import { VNodes, VCustomElement } from './vnodes';
|
|
2
|
+
import { VNode, VNodes, VCustomElement } from './vnodes';
|
|
3
3
|
export declare function patchChildren(c1: VNodes, c2: VNodes, parent: ParentNode): void;
|
|
4
|
+
export declare function mount(node: VNode, parent: ParentNode, anchor: Node | null): void;
|
|
5
|
+
export declare function removeNode(node: Node, parent: ParentNode): void;
|
|
4
6
|
export declare function allocateChildren(vnode: VCustomElement, vm: VM): void;
|
|
5
7
|
export declare function markAsDynamicChildren(children: VNodes): void;
|
package/types/framework/vm.d.ts
CHANGED
|
@@ -123,10 +123,8 @@ export interface VM<N = HostNode, E = HostElement> {
|
|
|
123
123
|
declare type VMAssociable = HostNode | LightningElement;
|
|
124
124
|
export declare function rerenderVM(vm: VM): void;
|
|
125
125
|
export declare function connectRootElement(elm: any): void;
|
|
126
|
-
export declare function hydrateRootElement(elm: any): void;
|
|
127
126
|
export declare function disconnectRootElement(elm: any): void;
|
|
128
127
|
export declare function appendVM(vm: VM): void;
|
|
129
|
-
export declare function hydrateVM(vm: VM): void;
|
|
130
128
|
export declare function removeVM(vm: VM): void;
|
|
131
129
|
export declare function createVM<HostNode, HostElement>(elm: HostElement, ctor: LightningElementConstructor, options: {
|
|
132
130
|
mode: ShadowRootMode;
|
|
@@ -136,6 +134,7 @@ export declare function createVM<HostNode, HostElement>(elm: HostElement, ctor:
|
|
|
136
134
|
export declare function associateVM(obj: VMAssociable, vm: VM): void;
|
|
137
135
|
export declare function getAssociatedVM(obj: VMAssociable): VM;
|
|
138
136
|
export declare function getAssociatedVMIfPresent(obj: VMAssociable): VM | undefined;
|
|
137
|
+
export declare function runRenderedCallback(vm: VM): void;
|
|
139
138
|
export declare function runConnectedCallback(vm: VM): void;
|
|
140
139
|
export declare function resetComponentRoot(vm: VM): void;
|
|
141
140
|
export declare function scheduleRehydration(vm: VM): void;
|