lwc 2.5.7 → 2.5.8
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-dom/esm/es2017/engine-dom.js +490 -68
- package/dist/engine-dom/iife/es2017/engine-dom.js +490 -67
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +306 -60
- package/dist/engine-dom/iife/es5/engine-dom.js +566 -129
- package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +363 -113
- package/dist/engine-dom/umd/es2017/engine-dom.js +490 -67
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +306 -60
- package/dist/engine-dom/umd/es5/engine-dom.js +566 -129
- package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +363 -113
- package/dist/engine-server/commonjs/es2017/engine-server.js +361 -11
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
- package/dist/engine-server/esm/es2017/engine-server.js +361 -11
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +8 -8
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
306
306
|
return attributeName;
|
|
307
307
|
}
|
|
308
|
-
/** version: 2.5.
|
|
308
|
+
/** version: 2.5.8 */
|
|
309
309
|
|
|
310
310
|
/*
|
|
311
311
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -485,7 +485,7 @@
|
|
|
485
485
|
setFeatureFlag(name, value);
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
/** version: 2.5.
|
|
488
|
+
/** version: 2.5.8 */
|
|
489
489
|
|
|
490
490
|
/* proxy-compat-disable */
|
|
491
491
|
|
|
@@ -537,6 +537,28 @@
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
540
|
+
} // Borrowed from Vue template compiler.
|
|
541
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
545
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
546
|
+
|
|
547
|
+
function parseStyleText(cssText) {
|
|
548
|
+
const styleMap = {};
|
|
549
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
550
|
+
|
|
551
|
+
for (const declaration of declarations) {
|
|
552
|
+
if (declaration) {
|
|
553
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
554
|
+
|
|
555
|
+
if (prop !== undefined && value !== undefined) {
|
|
556
|
+
styleMap[prop.trim()] = value.trim();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return styleMap;
|
|
540
562
|
}
|
|
541
563
|
/*
|
|
542
564
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -718,8 +740,8 @@
|
|
|
718
740
|
*/
|
|
719
741
|
|
|
720
742
|
|
|
721
|
-
function
|
|
722
|
-
let msg = `[LWC
|
|
743
|
+
function log(method, message, vm) {
|
|
744
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
723
745
|
|
|
724
746
|
if (!isUndefined$1(vm)) {
|
|
725
747
|
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
@@ -727,7 +749,7 @@
|
|
|
727
749
|
|
|
728
750
|
if (process.env.NODE_ENV === 'test') {
|
|
729
751
|
/* eslint-disable-next-line no-console */
|
|
730
|
-
console
|
|
752
|
+
console[method](msg);
|
|
731
753
|
return;
|
|
732
754
|
}
|
|
733
755
|
|
|
@@ -735,9 +757,17 @@
|
|
|
735
757
|
throw new Error(msg);
|
|
736
758
|
} catch (e) {
|
|
737
759
|
/* eslint-disable-next-line no-console */
|
|
738
|
-
console
|
|
760
|
+
console[method](e);
|
|
739
761
|
}
|
|
740
762
|
}
|
|
763
|
+
|
|
764
|
+
function logError(message, vm) {
|
|
765
|
+
log('error', message, vm);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function logWarn(message, vm) {
|
|
769
|
+
log('warn', message, vm);
|
|
770
|
+
}
|
|
741
771
|
/*
|
|
742
772
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
743
773
|
* All rights reserved.
|
|
@@ -4597,6 +4627,17 @@
|
|
|
4597
4627
|
modComputedStyle.create(vnode);
|
|
4598
4628
|
}
|
|
4599
4629
|
|
|
4630
|
+
function hydrateElmHook(vnode) {
|
|
4631
|
+
modEvents.create(vnode); // Attrs are already on the element.
|
|
4632
|
+
// modAttrs.create(vnode);
|
|
4633
|
+
|
|
4634
|
+
modProps.create(vnode); // Already set.
|
|
4635
|
+
// modStaticClassName.create(vnode);
|
|
4636
|
+
// modStaticStyle.create(vnode);
|
|
4637
|
+
// modComputedClassName.create(vnode);
|
|
4638
|
+
// modComputedStyle.create(vnode);
|
|
4639
|
+
}
|
|
4640
|
+
|
|
4600
4641
|
function fallbackElmHook(elm, vnode) {
|
|
4601
4642
|
const {
|
|
4602
4643
|
owner
|
|
@@ -4768,6 +4809,179 @@
|
|
|
4768
4809
|
}
|
|
4769
4810
|
}
|
|
4770
4811
|
|
|
4812
|
+
function isElementNode(node) {
|
|
4813
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4814
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
4815
|
+
}
|
|
4816
|
+
|
|
4817
|
+
function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
|
|
4818
|
+
const {
|
|
4819
|
+
data: {
|
|
4820
|
+
attrs = {}
|
|
4821
|
+
},
|
|
4822
|
+
owner: {
|
|
4823
|
+
renderer
|
|
4824
|
+
}
|
|
4825
|
+
} = vnode;
|
|
4826
|
+
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
4827
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4828
|
+
|
|
4829
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4830
|
+
const elmAttrValue = renderer.getAttribute(elm, attrName);
|
|
4831
|
+
|
|
4832
|
+
if (attrValue !== elmAttrValue) {
|
|
4833
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4834
|
+
nodesAreCompatible = false;
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
|
|
4838
|
+
return nodesAreCompatible;
|
|
4839
|
+
}
|
|
4840
|
+
|
|
4841
|
+
function vnodesAndElementHaveCompatibleClass(vnode, elm) {
|
|
4842
|
+
const {
|
|
4843
|
+
data: {
|
|
4844
|
+
className,
|
|
4845
|
+
classMap
|
|
4846
|
+
},
|
|
4847
|
+
owner: {
|
|
4848
|
+
renderer
|
|
4849
|
+
}
|
|
4850
|
+
} = vnode;
|
|
4851
|
+
let nodesAreCompatible = true;
|
|
4852
|
+
let vnodeClassName;
|
|
4853
|
+
|
|
4854
|
+
if (!isUndefined$1(className) && className !== elm.className) {
|
|
4855
|
+
// className is used when class is bound to an expr.
|
|
4856
|
+
nodesAreCompatible = false;
|
|
4857
|
+
vnodeClassName = className;
|
|
4858
|
+
} else if (!isUndefined$1(classMap)) {
|
|
4859
|
+
// classMap is used when class is set to static value.
|
|
4860
|
+
const classList = renderer.getClassList(elm);
|
|
4861
|
+
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
4862
|
+
|
|
4863
|
+
for (const name in classMap) {
|
|
4864
|
+
computedClassName += ' ' + name;
|
|
4865
|
+
|
|
4866
|
+
if (!classList.contains(name)) {
|
|
4867
|
+
nodesAreCompatible = false;
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4871
|
+
vnodeClassName = computedClassName.trim();
|
|
4872
|
+
|
|
4873
|
+
if (classList.length > keys(classMap).length) {
|
|
4874
|
+
nodesAreCompatible = false;
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
if (!nodesAreCompatible) {
|
|
4879
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
4880
|
+
}
|
|
4881
|
+
|
|
4882
|
+
return nodesAreCompatible;
|
|
4883
|
+
}
|
|
4884
|
+
|
|
4885
|
+
function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
|
|
4886
|
+
const {
|
|
4887
|
+
data: {
|
|
4888
|
+
style,
|
|
4889
|
+
styleDecls
|
|
4890
|
+
},
|
|
4891
|
+
owner: {
|
|
4892
|
+
renderer
|
|
4893
|
+
}
|
|
4894
|
+
} = vnode;
|
|
4895
|
+
const elmStyle = renderer.getAttribute(elm, 'style') || '';
|
|
4896
|
+
let vnodeStyle;
|
|
4897
|
+
let nodesAreCompatible = true;
|
|
4898
|
+
|
|
4899
|
+
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
4900
|
+
nodesAreCompatible = false;
|
|
4901
|
+
vnodeStyle = style;
|
|
4902
|
+
} else if (!isUndefined$1(styleDecls)) {
|
|
4903
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
4904
|
+
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
4905
|
+
|
|
4906
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
4907
|
+
const [prop, value, important] = styleDecls[i];
|
|
4908
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
4909
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
4910
|
+
|
|
4911
|
+
if (isUndefined$1(parsedPropValue)) {
|
|
4912
|
+
nodesAreCompatible = false;
|
|
4913
|
+
} else if (!parsedPropValue.startsWith(value)) {
|
|
4914
|
+
nodesAreCompatible = false;
|
|
4915
|
+
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
4916
|
+
nodesAreCompatible = false;
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
|
|
4920
|
+
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
4921
|
+
nodesAreCompatible = false;
|
|
4922
|
+
}
|
|
4923
|
+
|
|
4924
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
4925
|
+
}
|
|
4926
|
+
|
|
4927
|
+
if (!nodesAreCompatible) {
|
|
4928
|
+
// style is used when class is bound to an expr.
|
|
4929
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
4930
|
+
}
|
|
4931
|
+
|
|
4932
|
+
return nodesAreCompatible;
|
|
4933
|
+
}
|
|
4934
|
+
|
|
4935
|
+
function throwHydrationError() {
|
|
4936
|
+
assert.fail('Server rendered elements do not match client side generated elements');
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
4940
|
+
var _a, _b;
|
|
4941
|
+
|
|
4942
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4943
|
+
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
4944
|
+
|
|
4945
|
+
if (elmChildren.length !== filteredVNodes.length) {
|
|
4946
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4947
|
+
throwHydrationError();
|
|
4948
|
+
}
|
|
4949
|
+
}
|
|
4950
|
+
|
|
4951
|
+
let elmCurrentChildIdx = 0;
|
|
4952
|
+
|
|
4953
|
+
for (let j = 0, n = children.length; j < n; j++) {
|
|
4954
|
+
const ch = children[j];
|
|
4955
|
+
|
|
4956
|
+
if (ch != null) {
|
|
4957
|
+
const childNode = elmChildren[elmCurrentChildIdx];
|
|
4958
|
+
|
|
4959
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4960
|
+
// VComments and VTexts validation is handled in their hooks
|
|
4961
|
+
if (isElementNode(childNode)) {
|
|
4962
|
+
if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
|
|
4963
|
+
logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
|
|
4964
|
+
throwHydrationError();
|
|
4965
|
+
} // Note: props are not yet set
|
|
4966
|
+
|
|
4967
|
+
|
|
4968
|
+
const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
|
|
4969
|
+
const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
|
|
4970
|
+
const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
|
|
4971
|
+
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
4972
|
+
|
|
4973
|
+
if (!isVNodeAndElementCompatible) {
|
|
4974
|
+
throwHydrationError();
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
|
|
4979
|
+
ch.hook.hydrate(ch, childNode);
|
|
4980
|
+
elmCurrentChildIdx++;
|
|
4981
|
+
}
|
|
4982
|
+
}
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4771
4985
|
function updateCustomElmHook(oldVnode, vnode) {
|
|
4772
4986
|
// Attrs need to be applied to element before props
|
|
4773
4987
|
// IE11 will wipe out value on radio inputs if value
|
|
@@ -4869,7 +5083,26 @@
|
|
|
4869
5083
|
update: updateNodeHook,
|
|
4870
5084
|
insert: insertNodeHook,
|
|
4871
5085
|
move: insertNodeHook,
|
|
4872
|
-
remove: removeNodeHook
|
|
5086
|
+
remove: removeNodeHook,
|
|
5087
|
+
hydrate: (vNode, node) => {
|
|
5088
|
+
var _a;
|
|
5089
|
+
|
|
5090
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5091
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5092
|
+
if (node.nodeType !== Node.TEXT_NODE) {
|
|
5093
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5094
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5095
|
+
}
|
|
5096
|
+
|
|
5097
|
+
if (node.nodeValue !== vNode.text) {
|
|
5098
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
|
|
5099
|
+
}
|
|
5100
|
+
} // always set the text value to the one from the vnode.
|
|
5101
|
+
|
|
5102
|
+
|
|
5103
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
5104
|
+
vNode.elm = node;
|
|
5105
|
+
}
|
|
4873
5106
|
};
|
|
4874
5107
|
const CommentHook = {
|
|
4875
5108
|
create: vnode => {
|
|
@@ -4887,7 +5120,26 @@
|
|
|
4887
5120
|
update: updateNodeHook,
|
|
4888
5121
|
insert: insertNodeHook,
|
|
4889
5122
|
move: insertNodeHook,
|
|
4890
|
-
remove: removeNodeHook
|
|
5123
|
+
remove: removeNodeHook,
|
|
5124
|
+
hydrate: (vNode, node) => {
|
|
5125
|
+
var _a;
|
|
5126
|
+
|
|
5127
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5128
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5129
|
+
if (node.nodeType !== Node.COMMENT_NODE) {
|
|
5130
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5131
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5132
|
+
}
|
|
5133
|
+
|
|
5134
|
+
if (node.nodeValue !== vNode.text) {
|
|
5135
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
|
|
5136
|
+
}
|
|
5137
|
+
} // always set the text value to the one from the vnode.
|
|
5138
|
+
|
|
5139
|
+
|
|
5140
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
5141
|
+
vNode.elm = node;
|
|
5142
|
+
}
|
|
4891
5143
|
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4892
5144
|
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4893
5145
|
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
@@ -4927,6 +5179,38 @@
|
|
|
4927
5179
|
remove: (vnode, parentNode) => {
|
|
4928
5180
|
removeNodeHook(vnode, parentNode);
|
|
4929
5181
|
removeElmHook(vnode);
|
|
5182
|
+
},
|
|
5183
|
+
hydrate: (vnode, node) => {
|
|
5184
|
+
const elm = node;
|
|
5185
|
+
vnode.elm = elm;
|
|
5186
|
+
const {
|
|
5187
|
+
context
|
|
5188
|
+
} = vnode.data;
|
|
5189
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
5190
|
+
/* manual */
|
|
5191
|
+
);
|
|
5192
|
+
|
|
5193
|
+
if (isDomManual) {
|
|
5194
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5195
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5196
|
+
const {
|
|
5197
|
+
props
|
|
5198
|
+
} = vnode.data;
|
|
5199
|
+
|
|
5200
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5201
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
5202
|
+
delete props.innerHTML;
|
|
5203
|
+
} else {
|
|
5204
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
5208
|
+
|
|
5209
|
+
hydrateElmHook(vnode);
|
|
5210
|
+
|
|
5211
|
+
if (!isDomManual) {
|
|
5212
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
5213
|
+
}
|
|
4930
5214
|
}
|
|
4931
5215
|
};
|
|
4932
5216
|
const CustomElementHook = {
|
|
@@ -5018,6 +5302,44 @@
|
|
|
5018
5302
|
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
5019
5303
|
removeVM(vm);
|
|
5020
5304
|
}
|
|
5305
|
+
},
|
|
5306
|
+
hydrate: (vnode, elm) => {
|
|
5307
|
+
// the element is created, but the vm is not
|
|
5308
|
+
const {
|
|
5309
|
+
sel,
|
|
5310
|
+
mode,
|
|
5311
|
+
ctor,
|
|
5312
|
+
owner
|
|
5313
|
+
} = vnode;
|
|
5314
|
+
const def = getComponentInternalDef(ctor);
|
|
5315
|
+
createVM(elm, def, {
|
|
5316
|
+
mode,
|
|
5317
|
+
owner,
|
|
5318
|
+
tagName: sel,
|
|
5319
|
+
renderer: owner.renderer
|
|
5320
|
+
});
|
|
5321
|
+
vnode.elm = elm;
|
|
5322
|
+
const vm = getAssociatedVM(elm);
|
|
5323
|
+
allocateChildrenHook(vnode, vm);
|
|
5324
|
+
hydrateElmHook(vnode); // Insert hook section:
|
|
5325
|
+
|
|
5326
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5327
|
+
assert.isTrue(vm.state === 0
|
|
5328
|
+
/* created */
|
|
5329
|
+
, `${vm} cannot be recycled.`);
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
runConnectedCallback(vm);
|
|
5333
|
+
|
|
5334
|
+
if (vm.renderMode !== 0
|
|
5335
|
+
/* Light */
|
|
5336
|
+
) {
|
|
5337
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5338
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5339
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
hydrateVM(vm);
|
|
5021
5343
|
}
|
|
5022
5344
|
};
|
|
5023
5345
|
|
|
@@ -5706,7 +6028,10 @@
|
|
|
5706
6028
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5707
6029
|
renderer.insertGlobalStylesheet(stylesheets[i]);
|
|
5708
6030
|
}
|
|
5709
|
-
} else if (renderer.ssr) {
|
|
6031
|
+
} else if (renderer.ssr || renderer.isHydrating) {
|
|
6032
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
6033
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
6034
|
+
// the first time the VM renders.
|
|
5710
6035
|
// native shadow or light DOM, SSR
|
|
5711
6036
|
const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
|
|
5712
6037
|
return createInlineStyleVNode(combinedStylesheetContent);
|
|
@@ -6331,6 +6656,12 @@
|
|
|
6331
6656
|
, vm);
|
|
6332
6657
|
}
|
|
6333
6658
|
|
|
6659
|
+
function hydrateRootElement(elm) {
|
|
6660
|
+
const vm = getAssociatedVM(elm);
|
|
6661
|
+
runConnectedCallback(vm);
|
|
6662
|
+
hydrateVM(vm);
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6334
6665
|
function disconnectRootElement(elm) {
|
|
6335
6666
|
const vm = getAssociatedVM(elm);
|
|
6336
6667
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -6338,6 +6669,10 @@
|
|
|
6338
6669
|
|
|
6339
6670
|
function appendVM(vm) {
|
|
6340
6671
|
rehydrate(vm);
|
|
6672
|
+
}
|
|
6673
|
+
|
|
6674
|
+
function hydrateVM(vm) {
|
|
6675
|
+
hydrate(vm);
|
|
6341
6676
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6342
6677
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6343
6678
|
|
|
@@ -6571,6 +6906,22 @@
|
|
|
6571
6906
|
}
|
|
6572
6907
|
}
|
|
6573
6908
|
|
|
6909
|
+
function hydrate(vm) {
|
|
6910
|
+
if (isTrue(vm.isDirty)) {
|
|
6911
|
+
// manually diffing/patching here.
|
|
6912
|
+
// This routine is:
|
|
6913
|
+
// patchShadowRoot(vm, children);
|
|
6914
|
+
// -> addVnodes.
|
|
6915
|
+
const children = renderComponent(vm);
|
|
6916
|
+
vm.children = children;
|
|
6917
|
+
const vmChildren = vm.renderMode === 0
|
|
6918
|
+
/* Light */
|
|
6919
|
+
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
6920
|
+
hydrateChildrenHook(vmChildren, children, vm);
|
|
6921
|
+
runRenderedCallback(vm);
|
|
6922
|
+
}
|
|
6923
|
+
}
|
|
6924
|
+
|
|
6574
6925
|
function patchShadowRoot(vm, newCh) {
|
|
6575
6926
|
const {
|
|
6576
6927
|
children: oldCh
|
|
@@ -7402,7 +7753,7 @@
|
|
|
7402
7753
|
hooksAreSet = true;
|
|
7403
7754
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7404
7755
|
}
|
|
7405
|
-
/* version: 2.5.
|
|
7756
|
+
/* version: 2.5.8 */
|
|
7406
7757
|
|
|
7407
7758
|
/*
|
|
7408
7759
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7546,8 +7897,19 @@
|
|
|
7546
7897
|
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7547
7898
|
}
|
|
7548
7899
|
|
|
7900
|
+
let isHydrating = false;
|
|
7901
|
+
|
|
7902
|
+
function setIsHydrating(v) {
|
|
7903
|
+
isHydrating = v;
|
|
7904
|
+
}
|
|
7905
|
+
|
|
7549
7906
|
const renderer = {
|
|
7550
7907
|
ssr: false,
|
|
7908
|
+
|
|
7909
|
+
get isHydrating() {
|
|
7910
|
+
return isHydrating;
|
|
7911
|
+
},
|
|
7912
|
+
|
|
7551
7913
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7552
7914
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7553
7915
|
|
|
@@ -7576,6 +7938,10 @@
|
|
|
7576
7938
|
},
|
|
7577
7939
|
|
|
7578
7940
|
attachShadow(element, options) {
|
|
7941
|
+
if (isHydrating) {
|
|
7942
|
+
return element.shadowRoot;
|
|
7943
|
+
}
|
|
7944
|
+
|
|
7579
7945
|
return element.attachShadow(options);
|
|
7580
7946
|
},
|
|
7581
7947
|
|
|
@@ -7713,61 +8079,6 @@
|
|
|
7713
8079
|
getCustomElement,
|
|
7714
8080
|
HTMLElement: HTMLElementConstructor
|
|
7715
8081
|
};
|
|
7716
|
-
/*
|
|
7717
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
7718
|
-
* All rights reserved.
|
|
7719
|
-
* SPDX-License-Identifier: MIT
|
|
7720
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7721
|
-
*/
|
|
7722
|
-
|
|
7723
|
-
/**
|
|
7724
|
-
* This function builds a Web Component class from a LWC constructor so it can be
|
|
7725
|
-
* registered as a new element via customElements.define() at any given time.
|
|
7726
|
-
*
|
|
7727
|
-
* @deprecated since version 1.3.11
|
|
7728
|
-
*
|
|
7729
|
-
* @example
|
|
7730
|
-
* ```
|
|
7731
|
-
* import { buildCustomElementConstructor } from 'lwc';
|
|
7732
|
-
* import Foo from 'ns/foo';
|
|
7733
|
-
* const WC = buildCustomElementConstructor(Foo);
|
|
7734
|
-
* customElements.define('x-foo', WC);
|
|
7735
|
-
* const elm = document.createElement('x-foo');
|
|
7736
|
-
* ```
|
|
7737
|
-
*/
|
|
7738
|
-
|
|
7739
|
-
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
7740
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7741
|
-
/* eslint-disable-next-line no-console */
|
|
7742
|
-
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
7743
|
-
}
|
|
7744
|
-
|
|
7745
|
-
return Ctor.CustomElementConstructor;
|
|
7746
|
-
}
|
|
7747
|
-
|
|
7748
|
-
function buildCustomElementConstructor(Ctor) {
|
|
7749
|
-
const def = getComponentInternalDef(Ctor);
|
|
7750
|
-
return class extends def.bridge {
|
|
7751
|
-
constructor() {
|
|
7752
|
-
super();
|
|
7753
|
-
createVM(this, def, {
|
|
7754
|
-
mode: 'open',
|
|
7755
|
-
owner: null,
|
|
7756
|
-
tagName: this.tagName,
|
|
7757
|
-
renderer
|
|
7758
|
-
});
|
|
7759
|
-
}
|
|
7760
|
-
|
|
7761
|
-
connectedCallback() {
|
|
7762
|
-
connectRootElement(this);
|
|
7763
|
-
}
|
|
7764
|
-
|
|
7765
|
-
disconnectedCallback() {
|
|
7766
|
-
disconnectRootElement(this);
|
|
7767
|
-
}
|
|
7768
|
-
|
|
7769
|
-
};
|
|
7770
|
-
}
|
|
7771
8082
|
/*
|
|
7772
8083
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7773
8084
|
* All rights reserved.
|
|
@@ -7777,7 +8088,6 @@
|
|
|
7777
8088
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
7778
8089
|
// eslint-disable-next-line lwc-internal/no-global-node
|
|
7779
8090
|
|
|
7780
|
-
|
|
7781
8091
|
const _Node$1 = Node;
|
|
7782
8092
|
const ConnectingSlot = new WeakMap();
|
|
7783
8093
|
const DisconnectingSlot = new WeakMap();
|
|
@@ -7888,6 +8198,118 @@
|
|
|
7888
8198
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7889
8199
|
*/
|
|
7890
8200
|
|
|
8201
|
+
|
|
8202
|
+
function hydrateComponent(element, Ctor, props = {}) {
|
|
8203
|
+
if (!isFunction$1(Ctor)) {
|
|
8204
|
+
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8205
|
+
}
|
|
8206
|
+
|
|
8207
|
+
if (!isObject(props) || isNull(props)) {
|
|
8208
|
+
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8209
|
+
}
|
|
8210
|
+
|
|
8211
|
+
const def = getComponentInternalDef(Ctor);
|
|
8212
|
+
|
|
8213
|
+
try {
|
|
8214
|
+
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8215
|
+
// and uses the same algo to create the stylesheets as in SSR.
|
|
8216
|
+
setIsHydrating(true);
|
|
8217
|
+
createVM(element, def, {
|
|
8218
|
+
mode: 'open',
|
|
8219
|
+
owner: null,
|
|
8220
|
+
renderer,
|
|
8221
|
+
tagName: element.tagName.toLowerCase()
|
|
8222
|
+
});
|
|
8223
|
+
|
|
8224
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8225
|
+
element[key] = value;
|
|
8226
|
+
}
|
|
8227
|
+
|
|
8228
|
+
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8229
|
+
|
|
8230
|
+
setIsHydrating(false);
|
|
8231
|
+
} catch (e) {
|
|
8232
|
+
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
|
|
8233
|
+
// the client generated DOM.
|
|
8234
|
+
|
|
8235
|
+
/* eslint-disable-next-line no-console */
|
|
8236
|
+
console.error('Recovering from error while hydrating: ', e);
|
|
8237
|
+
setIsHydrating(false);
|
|
8238
|
+
const newElem = createElement(element.tagName, {
|
|
8239
|
+
is: Ctor,
|
|
8240
|
+
mode: 'open'
|
|
8241
|
+
});
|
|
8242
|
+
|
|
8243
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8244
|
+
newElem[key] = value;
|
|
8245
|
+
}
|
|
8246
|
+
|
|
8247
|
+
element.parentNode.replaceChild(newElem, element);
|
|
8248
|
+
}
|
|
8249
|
+
}
|
|
8250
|
+
/*
|
|
8251
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8252
|
+
* All rights reserved.
|
|
8253
|
+
* SPDX-License-Identifier: MIT
|
|
8254
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8255
|
+
*/
|
|
8256
|
+
|
|
8257
|
+
/**
|
|
8258
|
+
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8259
|
+
* registered as a new element via customElements.define() at any given time.
|
|
8260
|
+
*
|
|
8261
|
+
* @deprecated since version 1.3.11
|
|
8262
|
+
*
|
|
8263
|
+
* @example
|
|
8264
|
+
* ```
|
|
8265
|
+
* import { buildCustomElementConstructor } from 'lwc';
|
|
8266
|
+
* import Foo from 'ns/foo';
|
|
8267
|
+
* const WC = buildCustomElementConstructor(Foo);
|
|
8268
|
+
* customElements.define('x-foo', WC);
|
|
8269
|
+
* const elm = document.createElement('x-foo');
|
|
8270
|
+
* ```
|
|
8271
|
+
*/
|
|
8272
|
+
|
|
8273
|
+
|
|
8274
|
+
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8275
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8276
|
+
/* eslint-disable-next-line no-console */
|
|
8277
|
+
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
8278
|
+
}
|
|
8279
|
+
|
|
8280
|
+
return Ctor.CustomElementConstructor;
|
|
8281
|
+
}
|
|
8282
|
+
|
|
8283
|
+
function buildCustomElementConstructor(Ctor) {
|
|
8284
|
+
const def = getComponentInternalDef(Ctor);
|
|
8285
|
+
return class extends def.bridge {
|
|
8286
|
+
constructor() {
|
|
8287
|
+
super();
|
|
8288
|
+
createVM(this, def, {
|
|
8289
|
+
mode: 'open',
|
|
8290
|
+
owner: null,
|
|
8291
|
+
tagName: this.tagName,
|
|
8292
|
+
renderer
|
|
8293
|
+
});
|
|
8294
|
+
}
|
|
8295
|
+
|
|
8296
|
+
connectedCallback() {
|
|
8297
|
+
connectRootElement(this);
|
|
8298
|
+
}
|
|
8299
|
+
|
|
8300
|
+
disconnectedCallback() {
|
|
8301
|
+
disconnectRootElement(this);
|
|
8302
|
+
}
|
|
8303
|
+
|
|
8304
|
+
};
|
|
8305
|
+
}
|
|
8306
|
+
/*
|
|
8307
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8308
|
+
* All rights reserved.
|
|
8309
|
+
* SPDX-License-Identifier: MIT
|
|
8310
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8311
|
+
*/
|
|
8312
|
+
|
|
7891
8313
|
/**
|
|
7892
8314
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
7893
8315
|
* This API is subject to change or being removed.
|
|
@@ -7987,7 +8409,7 @@
|
|
|
7987
8409
|
});
|
|
7988
8410
|
freeze(LightningElement);
|
|
7989
8411
|
seal(LightningElement.prototype);
|
|
7990
|
-
/* version: 2.5.
|
|
8412
|
+
/* version: 2.5.8 */
|
|
7991
8413
|
|
|
7992
8414
|
exports.LightningElement = LightningElement;
|
|
7993
8415
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -7997,6 +8419,7 @@
|
|
|
7997
8419
|
exports.createElement = createElement;
|
|
7998
8420
|
exports.getComponentConstructor = getComponentConstructor;
|
|
7999
8421
|
exports.getComponentDef = getComponentDef;
|
|
8422
|
+
exports.hydrateComponent = hydrateComponent;
|
|
8000
8423
|
exports.isComponentConstructor = isComponentConstructor;
|
|
8001
8424
|
exports.isNodeFromTemplate = isNodeFromTemplate;
|
|
8002
8425
|
exports.readonly = readonly;
|