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