@lwc/engine-core 2.7.4 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-core.cjs.js +466 -333
- package/dist/engine-core.js +467 -334
- package/package.json +4 -4
- package/types/framework/api.d.ts +2 -2
- package/types/framework/check-version-mismatch.d.ts +11 -0
- package/types/framework/hydration.d.ts +1 -1
- package/types/framework/rendering.d.ts +2 -6
- package/types/framework/template.d.ts +2 -2
- package/types/framework/utils.d.ts +7 -0
- package/types/framework/vnodes.d.ts +13 -20
- package/LICENSE +0 -10
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, 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, ArrayFilter } from '@lwc/shared';
|
|
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, ArrayFilter } from '@lwc/shared';
|
|
3
3
|
import { runtimeFlags } from '@lwc/features';
|
|
4
4
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
5
5
|
|
|
@@ -68,6 +68,31 @@ function parseStyleText(cssText) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
return styleMap;
|
|
71
|
+
} // Make a shallow copy of an object but omit the given key
|
|
72
|
+
|
|
73
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
74
|
+
const result = {};
|
|
75
|
+
|
|
76
|
+
for (const key of Object.keys(object)) {
|
|
77
|
+
if (key !== keyToOmit) {
|
|
78
|
+
result[key] = object[key];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
function flattenStylesheets(stylesheets) {
|
|
85
|
+
const list = [];
|
|
86
|
+
|
|
87
|
+
for (const stylesheet of stylesheets) {
|
|
88
|
+
if (!Array.isArray(stylesheet)) {
|
|
89
|
+
list.push(stylesheet);
|
|
90
|
+
} else {
|
|
91
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return list;
|
|
71
96
|
}
|
|
72
97
|
|
|
73
98
|
//
|
|
@@ -2762,6 +2787,45 @@ function getDecoratorsMeta(Ctor) {
|
|
|
2762
2787
|
return isUndefined$1(meta) ? defaultMeta : meta;
|
|
2763
2788
|
}
|
|
2764
2789
|
|
|
2790
|
+
/*
|
|
2791
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2792
|
+
* All rights reserved.
|
|
2793
|
+
* SPDX-License-Identifier: MIT
|
|
2794
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2795
|
+
*/
|
|
2796
|
+
let warned = false;
|
|
2797
|
+
|
|
2798
|
+
if (process.env.NODE_ENV === 'development') {
|
|
2799
|
+
// @ts-ignore
|
|
2800
|
+
window.__lwcResetWarnedOnVersionMismatch = () => {
|
|
2801
|
+
warned = false;
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
function checkVersionMismatch(func, type) {
|
|
2806
|
+
const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
|
|
2807
|
+
|
|
2808
|
+
if (!isNull(versionMatcher) && !warned) {
|
|
2809
|
+
const version = versionMatcher[1];
|
|
2810
|
+
const [major, minor] = version.split('.');
|
|
2811
|
+
const [expectedMajor, expectedMinor] = LWC_VERSION.split('.');
|
|
2812
|
+
|
|
2813
|
+
if (major !== expectedMajor || minor !== expectedMinor) {
|
|
2814
|
+
warned = true; // only warn once to avoid flooding the console
|
|
2815
|
+
// stylesheets and templates do not have user-meaningful names, but components do
|
|
2816
|
+
|
|
2817
|
+
const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
|
|
2818
|
+
logError(`LWC WARNING: current engine is v${LWC_VERSION}, but ${friendlyName} was compiled with v${version}.\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear.`);
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
/*
|
|
2824
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2825
|
+
* All rights reserved.
|
|
2826
|
+
* SPDX-License-Identifier: MIT
|
|
2827
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2828
|
+
*/
|
|
2765
2829
|
const signedTemplateSet = new Set();
|
|
2766
2830
|
function defaultEmptyTemplate() {
|
|
2767
2831
|
return [];
|
|
@@ -2770,12 +2834,27 @@ signedTemplateSet.add(defaultEmptyTemplate);
|
|
|
2770
2834
|
function isTemplateRegistered(tpl) {
|
|
2771
2835
|
return signedTemplateSet.has(tpl);
|
|
2772
2836
|
}
|
|
2837
|
+
|
|
2838
|
+
function checkTemplateVersionMismatch(template) {
|
|
2839
|
+
checkVersionMismatch(template, 'template');
|
|
2840
|
+
|
|
2841
|
+
if (!isUndefined$1(template.stylesheets)) {
|
|
2842
|
+
for (const stylesheet of flattenStylesheets(template.stylesheets)) {
|
|
2843
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2773
2847
|
/**
|
|
2774
2848
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
2775
2849
|
* will prevent this function from being imported by userland code.
|
|
2776
2850
|
*/
|
|
2777
2851
|
|
|
2852
|
+
|
|
2778
2853
|
function registerTemplate(tpl) {
|
|
2854
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2855
|
+
checkTemplateVersionMismatch(tpl);
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2779
2858
|
signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
|
|
2780
2859
|
// assignment of templates easily, without too much transformation
|
|
2781
2860
|
|
|
@@ -3067,20 +3146,6 @@ function rehydrateHotComponent(Ctor) {
|
|
|
3067
3146
|
return canRefreshAllInstances;
|
|
3068
3147
|
}
|
|
3069
3148
|
|
|
3070
|
-
function flattenStylesheets(stylesheets) {
|
|
3071
|
-
const list = [];
|
|
3072
|
-
|
|
3073
|
-
for (const stylesheet of stylesheets) {
|
|
3074
|
-
if (!Array.isArray(stylesheet)) {
|
|
3075
|
-
list.push(stylesheet);
|
|
3076
|
-
} else {
|
|
3077
|
-
list.push(...flattenStylesheets(stylesheet));
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
|
|
3081
|
-
return list;
|
|
3082
|
-
}
|
|
3083
|
-
|
|
3084
3149
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
3085
3150
|
if (process.env.NODE_ENV === 'production') {
|
|
3086
3151
|
// this method should never leak to prod
|
|
@@ -3892,156 +3957,268 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
3892
3957
|
* SPDX-License-Identifier: MIT
|
|
3893
3958
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3894
3959
|
*/
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
move: insertNode,
|
|
3907
|
-
remove: removeNode
|
|
3908
|
-
};
|
|
3909
|
-
const CommentHook = {
|
|
3910
|
-
create: vnode => {
|
|
3911
|
-
const {
|
|
3912
|
-
owner,
|
|
3913
|
-
text
|
|
3914
|
-
} = vnode;
|
|
3915
|
-
const elm = createComment(text);
|
|
3916
|
-
linkNodeToShadow(elm, owner);
|
|
3917
|
-
vnode.elm = elm;
|
|
3918
|
-
},
|
|
3919
|
-
update: updateNodeHook,
|
|
3920
|
-
insert: insertNode,
|
|
3921
|
-
move: insertNode,
|
|
3922
|
-
remove: removeNode
|
|
3923
|
-
}; // insert is called after update, which is used somewhere else (via a module)
|
|
3924
|
-
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
3925
|
-
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
3926
|
-
// which breaks some invariants. For that reason, we have the following for any
|
|
3927
|
-
// Custom Element that is inserted via a template.
|
|
3928
|
-
|
|
3929
|
-
const ElementHook = {
|
|
3930
|
-
create: vnode => {
|
|
3931
|
-
const {
|
|
3932
|
-
sel,
|
|
3933
|
-
owner,
|
|
3934
|
-
data: {
|
|
3935
|
-
svg
|
|
3936
|
-
}
|
|
3937
|
-
} = vnode;
|
|
3938
|
-
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3939
|
-
const elm = createElement(sel, namespace);
|
|
3940
|
-
linkNodeToShadow(elm, owner);
|
|
3941
|
-
fallbackElmHook(elm, vnode);
|
|
3942
|
-
vnode.elm = elm;
|
|
3943
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3944
|
-
},
|
|
3945
|
-
update: (oldVnode, vnode) => {
|
|
3946
|
-
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
3947
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
3948
|
-
},
|
|
3949
|
-
insert: (vnode, parentNode, referenceNode) => {
|
|
3950
|
-
insertNode(vnode, parentNode, referenceNode);
|
|
3951
|
-
createChildrenHook(vnode);
|
|
3952
|
-
},
|
|
3953
|
-
move: insertNode,
|
|
3954
|
-
remove: (vnode, parentNode) => {
|
|
3955
|
-
removeNode(vnode, parentNode);
|
|
3956
|
-
removeChildren(vnode);
|
|
3960
|
+
function patchChildren(c1, c2, parent) {
|
|
3961
|
+
if (hasDynamicChildren(c2)) {
|
|
3962
|
+
updateDynamicChildren(c1, c2, parent);
|
|
3963
|
+
} else {
|
|
3964
|
+
updateStaticChildren(c1, c2, parent);
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
function patch(n1, n2) {
|
|
3969
|
+
if (n1 === n2) {
|
|
3970
|
+
return;
|
|
3957
3971
|
}
|
|
3958
|
-
};
|
|
3959
|
-
const CustomElementHook = {
|
|
3960
|
-
create: vnode => {
|
|
3961
|
-
const {
|
|
3962
|
-
sel,
|
|
3963
|
-
owner
|
|
3964
|
-
} = vnode;
|
|
3965
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3966
|
-
/**
|
|
3967
|
-
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3968
|
-
* with a callback as the first argument, we could implement a more advanced
|
|
3969
|
-
* mechanism that only passes that argument if the constructor is known to be
|
|
3970
|
-
* an upgradable custom element.
|
|
3971
|
-
*/
|
|
3972
|
-
|
|
3973
|
-
let vm;
|
|
3974
|
-
const elm = new UpgradableConstructor(elm => {
|
|
3975
|
-
// the custom element from the registry is expecting an upgrade callback
|
|
3976
|
-
vm = createViewModelHook(elm, vnode);
|
|
3977
|
-
});
|
|
3978
|
-
linkNodeToShadow(elm, owner);
|
|
3979
|
-
vnode.elm = elm;
|
|
3980
3972
|
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3973
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3974
|
+
if (!isSameVnode(n1, n2)) {
|
|
3975
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
3976
|
+
sel: n1.sel,
|
|
3977
|
+
key: n1.key
|
|
3978
|
+
}) + ', ' + JSON.stringify({
|
|
3979
|
+
sel: n2.sel,
|
|
3980
|
+
key: n2.key
|
|
3981
|
+
}));
|
|
3985
3982
|
}
|
|
3983
|
+
}
|
|
3986
3984
|
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3985
|
+
switch (n2.type) {
|
|
3986
|
+
case 0
|
|
3987
|
+
/* Text */
|
|
3988
|
+
:
|
|
3989
|
+
patchText(n1, n2);
|
|
3990
|
+
break;
|
|
3992
3991
|
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
// will happen, but in native, it does allocate the light dom
|
|
3992
|
+
case 1
|
|
3993
|
+
/* Comment */
|
|
3994
|
+
:
|
|
3995
|
+
patchComment(n1, n2);
|
|
3996
|
+
break;
|
|
3999
3997
|
|
|
3998
|
+
case 2
|
|
3999
|
+
/* Element */
|
|
4000
|
+
:
|
|
4001
|
+
patchElement(n1, n2);
|
|
4002
|
+
break;
|
|
4000
4003
|
|
|
4001
|
-
|
|
4004
|
+
case 3
|
|
4005
|
+
/* CustomElement */
|
|
4006
|
+
:
|
|
4007
|
+
patchCustomElement(n1, n2);
|
|
4008
|
+
break;
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4002
4011
|
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4012
|
+
function mount(node, parent, anchor) {
|
|
4013
|
+
switch (node.type) {
|
|
4014
|
+
case 0
|
|
4015
|
+
/* Text */
|
|
4016
|
+
:
|
|
4017
|
+
mountText(node, parent, anchor);
|
|
4018
|
+
break;
|
|
4008
4019
|
|
|
4020
|
+
case 1
|
|
4021
|
+
/* Comment */
|
|
4022
|
+
:
|
|
4023
|
+
mountComment(node, parent, anchor);
|
|
4024
|
+
break;
|
|
4025
|
+
|
|
4026
|
+
case 2
|
|
4027
|
+
/* Element */
|
|
4028
|
+
:
|
|
4029
|
+
mountElement(node, parent, anchor);
|
|
4030
|
+
break;
|
|
4031
|
+
|
|
4032
|
+
case 3
|
|
4033
|
+
/* CustomElement */
|
|
4034
|
+
:
|
|
4035
|
+
mountCustomElement(node, parent, anchor);
|
|
4036
|
+
break;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
function patchText(n1, n2) {
|
|
4041
|
+
n2.elm = n1.elm;
|
|
4042
|
+
|
|
4043
|
+
if (n2.text !== n1.text) {
|
|
4044
|
+
updateTextContent(n2);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
function mountText(node, parent, anchor) {
|
|
4049
|
+
const {
|
|
4050
|
+
owner
|
|
4051
|
+
} = node;
|
|
4052
|
+
const textNode = node.elm = createText(node.text);
|
|
4053
|
+
linkNodeToShadow(textNode, owner);
|
|
4054
|
+
insertNode(textNode, parent, anchor);
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
function patchComment(n1, n2) {
|
|
4058
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
4059
|
+
// it is the case today.
|
|
4060
|
+
|
|
4061
|
+
if (n2.text !== n1.text) {
|
|
4062
|
+
updateTextContent(n2);
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
function mountComment(node, parent, anchor) {
|
|
4067
|
+
const {
|
|
4068
|
+
owner
|
|
4069
|
+
} = node;
|
|
4070
|
+
const commentNode = node.elm = createComment(node.text);
|
|
4071
|
+
linkNodeToShadow(commentNode, owner);
|
|
4072
|
+
insertNode(commentNode, parent, anchor);
|
|
4073
|
+
}
|
|
4009
4074
|
|
|
4010
|
-
|
|
4075
|
+
function mountElement(vnode, parent, anchor) {
|
|
4076
|
+
const {
|
|
4077
|
+
sel,
|
|
4078
|
+
owner,
|
|
4079
|
+
data: {
|
|
4080
|
+
svg
|
|
4011
4081
|
}
|
|
4012
|
-
}
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4082
|
+
} = vnode;
|
|
4083
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4084
|
+
const elm = createElement(sel, namespace);
|
|
4085
|
+
linkNodeToShadow(elm, owner);
|
|
4086
|
+
fallbackElmHook(elm, vnode);
|
|
4087
|
+
vnode.elm = elm;
|
|
4088
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4089
|
+
insertNode(elm, parent, anchor);
|
|
4090
|
+
mountVNodes(vnode.children, elm, null);
|
|
4091
|
+
}
|
|
4016
4092
|
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4093
|
+
function patchElement(n1, n2) {
|
|
4094
|
+
const elm = n2.elm = n1.elm;
|
|
4095
|
+
patchElementPropsAndAttrs$1(n1, n2);
|
|
4096
|
+
patchChildren(n1.children, n2.children, elm);
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4099
|
+
function mountCustomElement(vnode, parent, anchor) {
|
|
4100
|
+
const {
|
|
4101
|
+
sel,
|
|
4102
|
+
owner
|
|
4103
|
+
} = vnode;
|
|
4104
|
+
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4105
|
+
/**
|
|
4106
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4107
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4108
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4109
|
+
* an upgradable custom element.
|
|
4110
|
+
*/
|
|
4111
|
+
|
|
4112
|
+
let vm;
|
|
4113
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4114
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4115
|
+
vm = createViewModelHook(elm, vnode);
|
|
4116
|
+
});
|
|
4117
|
+
linkNodeToShadow(elm, owner);
|
|
4118
|
+
vnode.elm = elm;
|
|
4119
|
+
vnode.vm = vm;
|
|
4120
|
+
|
|
4121
|
+
if (vm) {
|
|
4122
|
+
allocateChildren(vnode, vm);
|
|
4123
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4124
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4128
|
+
insertNode(elm, parent, anchor);
|
|
4023
4129
|
|
|
4024
|
-
|
|
4130
|
+
if (vm) {
|
|
4131
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4132
|
+
assert.isTrue(vm.state === 0
|
|
4133
|
+
/* created */
|
|
4134
|
+
, `${vm} cannot be recycled.`);
|
|
4025
4135
|
}
|
|
4026
4136
|
|
|
4027
|
-
|
|
4137
|
+
runConnectedCallback(vm);
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
mountVNodes(vnode.children, elm, null);
|
|
4028
4141
|
|
|
4029
|
-
|
|
4030
|
-
|
|
4142
|
+
if (vm) {
|
|
4143
|
+
appendVM(vm);
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
function patchCustomElement(n1, n2) {
|
|
4148
|
+
const elm = n2.elm = n1.elm;
|
|
4149
|
+
const vm = n2.vm = n1.vm;
|
|
4150
|
+
patchElementPropsAndAttrs$1(n1, n2);
|
|
4151
|
+
|
|
4152
|
+
if (!isUndefined$1(vm)) {
|
|
4153
|
+
// in fallback mode, the allocation will always set children to
|
|
4154
|
+
// empty and delegate the real allocation to the slot elements
|
|
4155
|
+
allocateChildren(n2, vm);
|
|
4156
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
4157
|
+
// will happen, but in native, it does allocate the light dom
|
|
4158
|
+
|
|
4159
|
+
|
|
4160
|
+
patchChildren(n1.children, n2.children, elm);
|
|
4161
|
+
|
|
4162
|
+
if (!isUndefined$1(vm)) {
|
|
4163
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4164
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4165
|
+
rerenderVM(vm);
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
4170
|
+
for (; start < end; ++start) {
|
|
4171
|
+
const vnode = vnodes[start];
|
|
4172
|
+
|
|
4173
|
+
if (isVNode(vnode)) {
|
|
4174
|
+
mount(vnode, parent, anchor);
|
|
4031
4175
|
}
|
|
4032
|
-
}
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
|
|
4179
|
+
function unmount(vnode, parent, doRemove = false) {
|
|
4180
|
+
const {
|
|
4181
|
+
type,
|
|
4182
|
+
elm
|
|
4183
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4184
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
4185
|
+
|
|
4186
|
+
if (doRemove) {
|
|
4187
|
+
removeNode(elm, parent);
|
|
4188
|
+
}
|
|
4037
4189
|
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4190
|
+
switch (type) {
|
|
4191
|
+
case 2
|
|
4192
|
+
/* Element */
|
|
4193
|
+
:
|
|
4194
|
+
unmountVNodes(vnode.children, elm);
|
|
4195
|
+
break;
|
|
4196
|
+
|
|
4197
|
+
case 3
|
|
4198
|
+
/* CustomElement */
|
|
4199
|
+
:
|
|
4200
|
+
{
|
|
4201
|
+
const {
|
|
4202
|
+
vm
|
|
4203
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
4204
|
+
// children.
|
|
4205
|
+
|
|
4206
|
+
if (!isUndefined$1(vm)) {
|
|
4207
|
+
removeVM(vm);
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
|
|
4213
|
+
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
4214
|
+
for (; start < end; ++start) {
|
|
4215
|
+
const ch = vnodes[start];
|
|
4216
|
+
|
|
4217
|
+
if (isVNode(ch)) {
|
|
4218
|
+
unmount(ch, parent, doRemove);
|
|
4042
4219
|
}
|
|
4043
4220
|
}
|
|
4044
|
-
}
|
|
4221
|
+
}
|
|
4045
4222
|
|
|
4046
4223
|
function isVNode(vnode) {
|
|
4047
4224
|
return vnode != null;
|
|
@@ -4086,43 +4263,41 @@ function linkNodeToShadow(elm, owner) {
|
|
|
4086
4263
|
}
|
|
4087
4264
|
}
|
|
4088
4265
|
|
|
4089
|
-
function
|
|
4266
|
+
function updateTextContent(vnode) {
|
|
4090
4267
|
const {
|
|
4091
4268
|
elm,
|
|
4092
4269
|
text
|
|
4093
4270
|
} = vnode;
|
|
4094
4271
|
|
|
4095
|
-
if (
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
}
|
|
4272
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4273
|
+
unlockDomMutation();
|
|
4274
|
+
}
|
|
4099
4275
|
|
|
4100
|
-
|
|
4276
|
+
setText(elm, text);
|
|
4101
4277
|
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
}
|
|
4278
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4279
|
+
lockDomMutation();
|
|
4105
4280
|
}
|
|
4106
4281
|
}
|
|
4107
4282
|
|
|
4108
|
-
function insertNode(
|
|
4283
|
+
function insertNode(node, parent, anchor) {
|
|
4109
4284
|
if (process.env.NODE_ENV !== 'production') {
|
|
4110
4285
|
unlockDomMutation();
|
|
4111
4286
|
}
|
|
4112
4287
|
|
|
4113
|
-
insert(
|
|
4288
|
+
insert(node, parent, anchor);
|
|
4114
4289
|
|
|
4115
4290
|
if (process.env.NODE_ENV !== 'production') {
|
|
4116
4291
|
lockDomMutation();
|
|
4117
4292
|
}
|
|
4118
4293
|
}
|
|
4119
4294
|
|
|
4120
|
-
function removeNode(
|
|
4295
|
+
function removeNode(node, parent) {
|
|
4121
4296
|
if (process.env.NODE_ENV !== 'production') {
|
|
4122
4297
|
unlockDomMutation();
|
|
4123
4298
|
}
|
|
4124
4299
|
|
|
4125
|
-
remove(
|
|
4300
|
+
remove(node, parent);
|
|
4126
4301
|
|
|
4127
4302
|
if (process.env.NODE_ENV !== 'production') {
|
|
4128
4303
|
lockDomMutation();
|
|
@@ -4167,11 +4342,13 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4167
4342
|
) {
|
|
4168
4343
|
// this element will now accept any manual content inserted into it
|
|
4169
4344
|
observeElementChildNodes(elm);
|
|
4170
|
-
}
|
|
4171
|
-
// into each element from the template, so they can be styled accordingly.
|
|
4172
|
-
|
|
4345
|
+
}
|
|
4173
4346
|
|
|
4174
|
-
|
|
4347
|
+
if (!isUndefined$1(stylesheetToken)) {
|
|
4348
|
+
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
4349
|
+
// into each element from the template, so they can be styled accordingly.
|
|
4350
|
+
setElementShadowToken(elm, stylesheetToken);
|
|
4351
|
+
}
|
|
4175
4352
|
}
|
|
4176
4353
|
|
|
4177
4354
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -4193,13 +4370,6 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4193
4370
|
}
|
|
4194
4371
|
}
|
|
4195
4372
|
|
|
4196
|
-
function patchChildren(parent, oldCh, newCh) {
|
|
4197
|
-
if (hasDynamicChildren(newCh)) {
|
|
4198
|
-
updateDynamicChildren(parent, oldCh, newCh);
|
|
4199
|
-
} else {
|
|
4200
|
-
updateStaticChildren(parent, oldCh, newCh);
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
4373
|
function allocateChildren(vnode, vm) {
|
|
4204
4374
|
// A component with slots will re-render because:
|
|
4205
4375
|
// 1- There is a change of the internal state.
|
|
@@ -4257,7 +4427,9 @@ function createViewModelHook(elm, vnode) {
|
|
|
4257
4427
|
} = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
|
|
4258
4428
|
// into each element from the template, so they can be styled accordingly.
|
|
4259
4429
|
|
|
4260
|
-
|
|
4430
|
+
if (!isUndefined$1(stylesheetToken)) {
|
|
4431
|
+
setElementShadowToken(elm, stylesheetToken);
|
|
4432
|
+
}
|
|
4261
4433
|
}
|
|
4262
4434
|
|
|
4263
4435
|
vm = createVM(elm, ctor, {
|
|
@@ -4273,40 +4445,6 @@ function createViewModelHook(elm, vnode) {
|
|
|
4273
4445
|
return vm;
|
|
4274
4446
|
}
|
|
4275
4447
|
|
|
4276
|
-
function createChildrenHook(vnode) {
|
|
4277
|
-
const {
|
|
4278
|
-
elm,
|
|
4279
|
-
children
|
|
4280
|
-
} = vnode;
|
|
4281
|
-
|
|
4282
|
-
for (let j = 0; j < children.length; ++j) {
|
|
4283
|
-
const ch = children[j];
|
|
4284
|
-
|
|
4285
|
-
if (ch != null) {
|
|
4286
|
-
ch.hook.create(ch);
|
|
4287
|
-
ch.hook.insert(ch, elm, null);
|
|
4288
|
-
}
|
|
4289
|
-
}
|
|
4290
|
-
}
|
|
4291
|
-
|
|
4292
|
-
function removeChildren(vnode) {
|
|
4293
|
-
// this method only needs to search on child vnodes from template
|
|
4294
|
-
// to trigger the remove hook just in case some of those children
|
|
4295
|
-
// are custom elements.
|
|
4296
|
-
const {
|
|
4297
|
-
children,
|
|
4298
|
-
elm
|
|
4299
|
-
} = vnode;
|
|
4300
|
-
|
|
4301
|
-
for (let j = 0, len = children.length; j < len; ++j) {
|
|
4302
|
-
const ch = children[j];
|
|
4303
|
-
|
|
4304
|
-
if (!isNull(ch)) {
|
|
4305
|
-
ch.hook.remove(ch, elm);
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4308
|
-
}
|
|
4309
|
-
|
|
4310
4448
|
function allocateInSlot(vm, children) {
|
|
4311
4449
|
var _a;
|
|
4312
4450
|
|
|
@@ -4403,28 +4541,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
4403
4541
|
return map;
|
|
4404
4542
|
}
|
|
4405
4543
|
|
|
4406
|
-
function
|
|
4407
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
4408
|
-
const ch = vnodes[startIdx];
|
|
4409
|
-
|
|
4410
|
-
if (isVNode(ch)) {
|
|
4411
|
-
ch.hook.create(ch);
|
|
4412
|
-
ch.hook.insert(ch, parentElm, before);
|
|
4413
|
-
}
|
|
4414
|
-
}
|
|
4415
|
-
}
|
|
4416
|
-
|
|
4417
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
4418
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
4419
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
4420
|
-
|
|
4421
|
-
if (isVNode(ch)) {
|
|
4422
|
-
ch.hook.remove(ch, parentElm);
|
|
4423
|
-
}
|
|
4424
|
-
}
|
|
4425
|
-
}
|
|
4426
|
-
|
|
4427
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
4544
|
+
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
4428
4545
|
let oldStartIdx = 0;
|
|
4429
4546
|
let newStartIdx = 0;
|
|
4430
4547
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -4438,6 +4555,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4438
4555
|
let idxInOld;
|
|
4439
4556
|
let elmToMove;
|
|
4440
4557
|
let before;
|
|
4558
|
+
let clonedOldCh = false;
|
|
4441
4559
|
|
|
4442
4560
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4443
4561
|
if (!isVNode(oldStartVnode)) {
|
|
@@ -4449,23 +4567,23 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4449
4567
|
} else if (!isVNode(newEndVnode)) {
|
|
4450
4568
|
newEndVnode = newCh[--newEndIdx];
|
|
4451
4569
|
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4452
|
-
|
|
4570
|
+
patch(oldStartVnode, newStartVnode);
|
|
4453
4571
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
4454
4572
|
newStartVnode = newCh[++newStartIdx];
|
|
4455
4573
|
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4456
|
-
|
|
4574
|
+
patch(oldEndVnode, newEndVnode);
|
|
4457
4575
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
4458
4576
|
newEndVnode = newCh[--newEndIdx];
|
|
4459
4577
|
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4460
4578
|
// Vnode moved right
|
|
4461
|
-
|
|
4462
|
-
|
|
4579
|
+
patch(oldStartVnode, newEndVnode);
|
|
4580
|
+
insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
|
|
4463
4581
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
4464
4582
|
newEndVnode = newCh[--newEndIdx];
|
|
4465
4583
|
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4466
4584
|
// Vnode moved left
|
|
4467
|
-
|
|
4468
|
-
newStartVnode.
|
|
4585
|
+
patch(oldEndVnode, newStartVnode);
|
|
4586
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
4469
4587
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
4470
4588
|
newStartVnode = newCh[++newStartIdx];
|
|
4471
4589
|
} else {
|
|
@@ -4477,8 +4595,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4477
4595
|
|
|
4478
4596
|
if (isUndefined$1(idxInOld)) {
|
|
4479
4597
|
// New element
|
|
4480
|
-
newStartVnode.
|
|
4481
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
4598
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
4482
4599
|
newStartVnode = newCh[++newStartIdx];
|
|
4483
4600
|
} else {
|
|
4484
4601
|
elmToMove = oldCh[idxInOld];
|
|
@@ -4486,12 +4603,22 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4486
4603
|
if (isVNode(elmToMove)) {
|
|
4487
4604
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4488
4605
|
// New element
|
|
4489
|
-
newStartVnode.
|
|
4490
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
4606
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
4491
4607
|
} else {
|
|
4492
|
-
|
|
4608
|
+
patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
|
|
4609
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4610
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4611
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4612
|
+
// and only clone once.
|
|
4613
|
+
|
|
4614
|
+
if (!clonedOldCh) {
|
|
4615
|
+
clonedOldCh = true;
|
|
4616
|
+
oldCh = [...oldCh];
|
|
4617
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
4618
|
+
|
|
4619
|
+
|
|
4493
4620
|
oldCh[idxInOld] = undefined;
|
|
4494
|
-
|
|
4621
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
4495
4622
|
}
|
|
4496
4623
|
}
|
|
4497
4624
|
|
|
@@ -4512,66 +4639,56 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4512
4639
|
} while (!isVNode(n) && i < newChEnd);
|
|
4513
4640
|
|
|
4514
4641
|
before = isVNode(n) ? n.elm : null;
|
|
4515
|
-
|
|
4642
|
+
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
4516
4643
|
} else {
|
|
4517
|
-
|
|
4644
|
+
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
4518
4645
|
}
|
|
4519
4646
|
}
|
|
4520
4647
|
}
|
|
4521
4648
|
|
|
4522
|
-
function updateStaticChildren(
|
|
4523
|
-
const
|
|
4524
|
-
const
|
|
4649
|
+
function updateStaticChildren(c1, c2, parent) {
|
|
4650
|
+
const c1Length = c1.length;
|
|
4651
|
+
const c2Length = c2.length;
|
|
4525
4652
|
|
|
4526
|
-
if (
|
|
4653
|
+
if (c1Length === 0) {
|
|
4527
4654
|
// the old list is empty, we can directly insert anything new
|
|
4528
|
-
|
|
4655
|
+
mountVNodes(c2, parent, null);
|
|
4529
4656
|
return;
|
|
4530
4657
|
}
|
|
4531
4658
|
|
|
4532
|
-
if (
|
|
4659
|
+
if (c2Length === 0) {
|
|
4533
4660
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4534
4661
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4535
|
-
|
|
4662
|
+
unmountVNodes(c1, parent, true);
|
|
4536
4663
|
return;
|
|
4537
4664
|
} // if the old list is not empty, the new list MUST have the same
|
|
4538
4665
|
// amount of nodes, that's why we call this static children
|
|
4539
4666
|
|
|
4540
4667
|
|
|
4541
|
-
let
|
|
4668
|
+
let anchor = null;
|
|
4542
4669
|
|
|
4543
|
-
for (let i =
|
|
4544
|
-
const
|
|
4545
|
-
const
|
|
4670
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4671
|
+
const n1 = c1[i];
|
|
4672
|
+
const n2 = c2[i];
|
|
4546
4673
|
|
|
4547
|
-
if (
|
|
4548
|
-
if (isVNode(
|
|
4549
|
-
if (isVNode(
|
|
4550
|
-
// both vnodes
|
|
4551
|
-
|
|
4552
|
-
|
|
4674
|
+
if (n2 !== n1) {
|
|
4675
|
+
if (isVNode(n1)) {
|
|
4676
|
+
if (isVNode(n2)) {
|
|
4677
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4678
|
+
patch(n1, n2);
|
|
4679
|
+
anchor = n2.elm;
|
|
4553
4680
|
} else {
|
|
4554
4681
|
// removing the old vnode since the new one is null
|
|
4555
|
-
|
|
4682
|
+
unmount(n1, parent, true);
|
|
4556
4683
|
}
|
|
4557
|
-
} else if (isVNode(
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
4562
|
-
referenceElm = vnode.elm;
|
|
4684
|
+
} else if (isVNode(n2)) {
|
|
4685
|
+
mount(n2, parent, anchor);
|
|
4686
|
+
anchor = n2.elm;
|
|
4563
4687
|
}
|
|
4564
4688
|
}
|
|
4565
4689
|
}
|
|
4566
4690
|
}
|
|
4567
4691
|
|
|
4568
|
-
function patchVnode(oldVnode, vnode) {
|
|
4569
|
-
if (oldVnode !== vnode) {
|
|
4570
|
-
vnode.elm = oldVnode.elm;
|
|
4571
|
-
vnode.hook.update(oldVnode, vnode);
|
|
4572
|
-
}
|
|
4573
|
-
}
|
|
4574
|
-
|
|
4575
4692
|
/*
|
|
4576
4693
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4577
4694
|
* All rights reserved.
|
|
@@ -4585,7 +4702,7 @@ function addVNodeToChildLWC(vnode) {
|
|
|
4585
4702
|
} // [h]tml node
|
|
4586
4703
|
|
|
4587
4704
|
|
|
4588
|
-
function h(sel, data, children) {
|
|
4705
|
+
function h(sel, data, children = EmptyArray) {
|
|
4589
4706
|
const vmBeingRendered = getVMBeingRendered();
|
|
4590
4707
|
|
|
4591
4708
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -4621,7 +4738,6 @@ function h(sel, data, children) {
|
|
|
4621
4738
|
children,
|
|
4622
4739
|
elm,
|
|
4623
4740
|
key,
|
|
4624
|
-
hook: ElementHook,
|
|
4625
4741
|
owner: vmBeingRendered
|
|
4626
4742
|
};
|
|
4627
4743
|
} // [t]ab[i]ndex function
|
|
@@ -4708,7 +4824,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4708
4824
|
const {
|
|
4709
4825
|
key
|
|
4710
4826
|
} = data;
|
|
4711
|
-
let elm;
|
|
4827
|
+
let elm, aChildren, vm;
|
|
4712
4828
|
const vnode = {
|
|
4713
4829
|
type: 3
|
|
4714
4830
|
/* CustomElement */
|
|
@@ -4718,11 +4834,11 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4718
4834
|
children,
|
|
4719
4835
|
elm,
|
|
4720
4836
|
key,
|
|
4721
|
-
hook: CustomElementHook,
|
|
4722
4837
|
ctor: Ctor,
|
|
4723
4838
|
owner: vmBeingRendered,
|
|
4724
|
-
mode: 'open'
|
|
4725
|
-
|
|
4839
|
+
mode: 'open',
|
|
4840
|
+
aChildren,
|
|
4841
|
+
vm
|
|
4726
4842
|
};
|
|
4727
4843
|
addVNodeToChildLWC(vnode);
|
|
4728
4844
|
return vnode;
|
|
@@ -4852,7 +4968,6 @@ function t(text) {
|
|
|
4852
4968
|
text,
|
|
4853
4969
|
elm,
|
|
4854
4970
|
key,
|
|
4855
|
-
hook: TextHook,
|
|
4856
4971
|
owner: getVMBeingRendered()
|
|
4857
4972
|
};
|
|
4858
4973
|
} // [co]mment node
|
|
@@ -4868,7 +4983,6 @@ function co(text) {
|
|
|
4868
4983
|
text,
|
|
4869
4984
|
elm,
|
|
4870
4985
|
key,
|
|
4871
|
-
hook: CommentHook,
|
|
4872
4986
|
owner: getVMBeingRendered()
|
|
4873
4987
|
};
|
|
4874
4988
|
} // [d]ynamic text
|
|
@@ -4983,7 +5097,7 @@ let dynamicImportedComponentCounter = 0;
|
|
|
4983
5097
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4984
5098
|
*/
|
|
4985
5099
|
|
|
4986
|
-
function dc(sel, Ctor, data, children) {
|
|
5100
|
+
function dc(sel, Ctor, data, children = EmptyArray) {
|
|
4987
5101
|
if (process.env.NODE_ENV !== 'production') {
|
|
4988
5102
|
assert.isTrue(isString(sel), `dc() 1st argument sel must be a string.`);
|
|
4989
5103
|
assert.isTrue(isObject(data), `dc() 3nd argument data must be an object.`);
|
|
@@ -5007,10 +5121,14 @@ function dc(sel, Ctor, data, children) {
|
|
|
5007
5121
|
} // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
5008
5122
|
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
5009
5123
|
// element used for previous constructors.
|
|
5124
|
+
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
5125
|
+
// hoisting optimization.
|
|
5010
5126
|
|
|
5011
5127
|
|
|
5012
|
-
|
|
5013
|
-
|
|
5128
|
+
const newData = Object.assign(Object.assign({}, data), {
|
|
5129
|
+
key: `dc:${idx}:${data.key}`
|
|
5130
|
+
});
|
|
5131
|
+
return c(sel, Ctor, newData, children);
|
|
5014
5132
|
}
|
|
5015
5133
|
/**
|
|
5016
5134
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5130,12 +5248,14 @@ function updateStylesheetToken(vm, template) {
|
|
|
5130
5248
|
hasTokenInAttribute: oldHasTokenInAttribute
|
|
5131
5249
|
} = context;
|
|
5132
5250
|
|
|
5133
|
-
if (
|
|
5134
|
-
|
|
5135
|
-
|
|
5251
|
+
if (!isUndefined$1(oldToken)) {
|
|
5252
|
+
if (oldHasTokenInClass) {
|
|
5253
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
5254
|
+
}
|
|
5136
5255
|
|
|
5137
|
-
|
|
5138
|
-
|
|
5256
|
+
if (oldHasTokenInAttribute) {
|
|
5257
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
5258
|
+
}
|
|
5139
5259
|
} // Apply the new template styling token to the host element, if the new template has any
|
|
5140
5260
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
5141
5261
|
|
|
@@ -5713,6 +5833,10 @@ const signedTemplateMap = new Map();
|
|
|
5713
5833
|
function registerComponent(Ctor, {
|
|
5714
5834
|
tmpl
|
|
5715
5835
|
}) {
|
|
5836
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5837
|
+
checkVersionMismatch(Ctor, 'component');
|
|
5838
|
+
}
|
|
5839
|
+
|
|
5716
5840
|
signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
|
|
5717
5841
|
// without too much transformation
|
|
5718
5842
|
|
|
@@ -5829,7 +5953,7 @@ function invokeServiceHook(vm, cbs) {
|
|
|
5829
5953
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5830
5954
|
*/
|
|
5831
5955
|
|
|
5832
|
-
function hydrate
|
|
5956
|
+
function hydrate(vnode, node) {
|
|
5833
5957
|
switch (vnode.type) {
|
|
5834
5958
|
case 0
|
|
5835
5959
|
/* Text */
|
|
@@ -5861,16 +5985,18 @@ function hydrateText(vnode, node) {
|
|
|
5861
5985
|
var _a;
|
|
5862
5986
|
|
|
5863
5987
|
if (process.env.NODE_ENV !== 'production') {
|
|
5864
|
-
|
|
5865
|
-
|
|
5988
|
+
validateNodeType(vnode, node, 3
|
|
5989
|
+
/* TEXT */
|
|
5990
|
+
);
|
|
5991
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
5866
5992
|
|
|
5867
|
-
if (
|
|
5993
|
+
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5868
5994
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5869
5995
|
}
|
|
5870
5996
|
} // always set the text value to the one from the vnode.
|
|
5871
5997
|
|
|
5872
5998
|
|
|
5873
|
-
node
|
|
5999
|
+
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5874
6000
|
vnode.elm = node;
|
|
5875
6001
|
}
|
|
5876
6002
|
|
|
@@ -5878,23 +6004,25 @@ function hydrateComment(vnode, node) {
|
|
|
5878
6004
|
var _a;
|
|
5879
6005
|
|
|
5880
6006
|
if (process.env.NODE_ENV !== 'production') {
|
|
5881
|
-
|
|
5882
|
-
|
|
6007
|
+
validateNodeType(vnode, node, 8
|
|
6008
|
+
/* COMMENT */
|
|
6009
|
+
);
|
|
5883
6010
|
|
|
5884
|
-
if (node
|
|
6011
|
+
if (getProperty(node, 'nodeValue') !== vnode.text) {
|
|
5885
6012
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5886
6013
|
}
|
|
5887
6014
|
} // always set the text value to the one from the vnode.
|
|
5888
6015
|
|
|
5889
6016
|
|
|
5890
|
-
node
|
|
6017
|
+
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5891
6018
|
vnode.elm = node;
|
|
5892
6019
|
}
|
|
5893
6020
|
|
|
5894
6021
|
function hydrateElement(vnode, node) {
|
|
5895
6022
|
if (process.env.NODE_ENV !== 'production') {
|
|
5896
|
-
|
|
5897
|
-
|
|
6023
|
+
validateNodeType(vnode, node, 1
|
|
6024
|
+
/* ELEMENT */
|
|
6025
|
+
);
|
|
5898
6026
|
validateElement(vnode, node);
|
|
5899
6027
|
}
|
|
5900
6028
|
|
|
@@ -5915,10 +6043,13 @@ function hydrateElement(vnode, node) {
|
|
|
5915
6043
|
} = vnode.data;
|
|
5916
6044
|
|
|
5917
6045
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5918
|
-
if (elm
|
|
5919
|
-
|
|
6046
|
+
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
6047
|
+
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
6048
|
+
vnode.data = Object.assign(Object.assign({}, vnode.data), {
|
|
6049
|
+
props: cloneAndOmitKey(props, 'innerHTML')
|
|
6050
|
+
});
|
|
5920
6051
|
} else {
|
|
5921
|
-
logWarn(`Mismatch hydrating element <${elm
|
|
6052
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
5922
6053
|
}
|
|
5923
6054
|
}
|
|
5924
6055
|
}
|
|
@@ -5926,19 +6057,19 @@ function hydrateElement(vnode, node) {
|
|
|
5926
6057
|
patchElementPropsAndAttrs(vnode);
|
|
5927
6058
|
|
|
5928
6059
|
if (!isDomManual) {
|
|
5929
|
-
hydrateChildren(vnode.elm
|
|
6060
|
+
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vnode.owner);
|
|
5930
6061
|
}
|
|
5931
6062
|
}
|
|
5932
6063
|
|
|
5933
6064
|
function hydrateCustomElement(vnode, node) {
|
|
5934
6065
|
if (process.env.NODE_ENV !== 'production') {
|
|
5935
|
-
|
|
5936
|
-
|
|
6066
|
+
validateNodeType(vnode, node, 1
|
|
6067
|
+
/* ELEMENT */
|
|
6068
|
+
);
|
|
5937
6069
|
validateElement(vnode, node);
|
|
5938
6070
|
}
|
|
5939
6071
|
|
|
5940
6072
|
const elm = node;
|
|
5941
|
-
vnode.elm = elm;
|
|
5942
6073
|
const {
|
|
5943
6074
|
sel,
|
|
5944
6075
|
mode,
|
|
@@ -5950,6 +6081,8 @@ function hydrateCustomElement(vnode, node) {
|
|
|
5950
6081
|
owner,
|
|
5951
6082
|
tagName: sel
|
|
5952
6083
|
});
|
|
6084
|
+
vnode.elm = elm;
|
|
6085
|
+
vnode.vm = vm;
|
|
5953
6086
|
allocateChildren(vnode, vm);
|
|
5954
6087
|
patchElementPropsAndAttrs(vnode); // Insert hook section:
|
|
5955
6088
|
|
|
@@ -5966,7 +6099,7 @@ function hydrateCustomElement(vnode, node) {
|
|
|
5966
6099
|
) {
|
|
5967
6100
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5968
6101
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5969
|
-
hydrateChildren(vnode.elm
|
|
6102
|
+
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vm);
|
|
5970
6103
|
}
|
|
5971
6104
|
|
|
5972
6105
|
hydrateVM(vm);
|
|
@@ -5989,7 +6122,7 @@ function hydrateChildren(elmChildren, children, vm) {
|
|
|
5989
6122
|
|
|
5990
6123
|
if (!isNull(childVnode)) {
|
|
5991
6124
|
const childNode = elmChildren[childNodeIndex];
|
|
5992
|
-
hydrate
|
|
6125
|
+
hydrate(childVnode, childNode);
|
|
5993
6126
|
childNodeIndex++;
|
|
5994
6127
|
}
|
|
5995
6128
|
}
|
|
@@ -6005,15 +6138,15 @@ function throwHydrationError() {
|
|
|
6005
6138
|
}
|
|
6006
6139
|
|
|
6007
6140
|
function validateNodeType(vnode, node, nodeType) {
|
|
6008
|
-
if (node
|
|
6141
|
+
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6009
6142
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6010
6143
|
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
6011
6144
|
}
|
|
6012
6145
|
}
|
|
6013
6146
|
|
|
6014
6147
|
function validateElement(vnode, elm) {
|
|
6015
|
-
if (vnode.sel.toLowerCase() !== elm
|
|
6016
|
-
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${elm
|
|
6148
|
+
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
|
6149
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6017
6150
|
throwHydrationError();
|
|
6018
6151
|
}
|
|
6019
6152
|
|
|
@@ -6040,7 +6173,7 @@ function validateAttrs(vnode, elm) {
|
|
|
6040
6173
|
const elmAttrValue = getAttribute(elm, attrName);
|
|
6041
6174
|
|
|
6042
6175
|
if (String(attrValue) !== elmAttrValue) {
|
|
6043
|
-
logError(`Mismatch hydrating element <${elm
|
|
6176
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6044
6177
|
nodesAreCompatible = false;
|
|
6045
6178
|
}
|
|
6046
6179
|
}
|
|
@@ -6058,7 +6191,7 @@ function validateClassAttr(vnode, elm) {
|
|
|
6058
6191
|
let nodesAreCompatible = true;
|
|
6059
6192
|
let vnodeClassName;
|
|
6060
6193
|
|
|
6061
|
-
if (!isUndefined$1(className) && String(className) !== elm
|
|
6194
|
+
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
6062
6195
|
// className is used when class is bound to an expr.
|
|
6063
6196
|
nodesAreCompatible = false;
|
|
6064
6197
|
vnodeClassName = className;
|
|
@@ -6083,7 +6216,7 @@ function validateClassAttr(vnode, elm) {
|
|
|
6083
6216
|
}
|
|
6084
6217
|
|
|
6085
6218
|
if (!nodesAreCompatible) {
|
|
6086
|
-
logError(`Mismatch hydrating element <${elm
|
|
6219
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty(elm, 'className')}"`, vnode.owner);
|
|
6087
6220
|
}
|
|
6088
6221
|
|
|
6089
6222
|
return nodesAreCompatible;
|
|
@@ -6130,7 +6263,7 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6130
6263
|
|
|
6131
6264
|
if (!nodesAreCompatible) {
|
|
6132
6265
|
// style is used when class is bound to an expr.
|
|
6133
|
-
logError(`Mismatch hydrating element <${elm
|
|
6266
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6134
6267
|
}
|
|
6135
6268
|
|
|
6136
6269
|
return nodesAreCompatible;
|
|
@@ -6194,7 +6327,19 @@ function appendVM(vm) {
|
|
|
6194
6327
|
rehydrate(vm);
|
|
6195
6328
|
}
|
|
6196
6329
|
function hydrateVM(vm) {
|
|
6197
|
-
|
|
6330
|
+
if (isTrue(vm.isDirty)) {
|
|
6331
|
+
// manually diffing/patching here.
|
|
6332
|
+
// This routine is:
|
|
6333
|
+
// patchShadowRoot(vm, children);
|
|
6334
|
+
// -> addVnodes.
|
|
6335
|
+
const children = renderComponent(vm);
|
|
6336
|
+
vm.children = children;
|
|
6337
|
+
const vmChildren = vm.renderMode === 0
|
|
6338
|
+
/* Light */
|
|
6339
|
+
? getChildNodes(vm.elm) : getChildNodes(vm.elm.shadowRoot);
|
|
6340
|
+
hydrateChildren(vmChildren, children, vm);
|
|
6341
|
+
runRenderedCallback(vm);
|
|
6342
|
+
}
|
|
6198
6343
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6199
6344
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6200
6345
|
|
|
@@ -6344,7 +6489,11 @@ function computeShadowMode(vm) {
|
|
|
6344
6489
|
/* Native */
|
|
6345
6490
|
;
|
|
6346
6491
|
} else if (isNativeShadowDefined) {
|
|
6347
|
-
if (
|
|
6492
|
+
if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
|
|
6493
|
+
shadowMode = 1
|
|
6494
|
+
/* Synthetic */
|
|
6495
|
+
;
|
|
6496
|
+
} else if (def.shadowSupportMode === "any"
|
|
6348
6497
|
/* Any */
|
|
6349
6498
|
) {
|
|
6350
6499
|
shadowMode = 0
|
|
@@ -6422,22 +6571,6 @@ function rehydrate(vm) {
|
|
|
6422
6571
|
}
|
|
6423
6572
|
}
|
|
6424
6573
|
|
|
6425
|
-
function hydrate(vm) {
|
|
6426
|
-
if (isTrue(vm.isDirty)) {
|
|
6427
|
-
// manually diffing/patching here.
|
|
6428
|
-
// This routine is:
|
|
6429
|
-
// patchShadowRoot(vm, children);
|
|
6430
|
-
// -> addVnodes.
|
|
6431
|
-
const children = renderComponent(vm);
|
|
6432
|
-
vm.children = children;
|
|
6433
|
-
const vmChildren = vm.renderMode === 0
|
|
6434
|
-
/* Light */
|
|
6435
|
-
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
6436
|
-
hydrateChildren(vmChildren, children, vm);
|
|
6437
|
-
runRenderedCallback(vm);
|
|
6438
|
-
}
|
|
6439
|
-
}
|
|
6440
|
-
|
|
6441
6574
|
function patchShadowRoot(vm, newCh) {
|
|
6442
6575
|
const {
|
|
6443
6576
|
renderRoot,
|
|
@@ -6457,7 +6590,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
6457
6590
|
, vm);
|
|
6458
6591
|
}, () => {
|
|
6459
6592
|
// job
|
|
6460
|
-
patchChildren(
|
|
6593
|
+
patchChildren(oldCh, newCh, renderRoot);
|
|
6461
6594
|
}, () => {
|
|
6462
6595
|
// post
|
|
6463
6596
|
logOperationEnd(2
|
|
@@ -7192,4 +7325,4 @@ function setHooks(hooks) {
|
|
|
7192
7325
|
}
|
|
7193
7326
|
|
|
7194
7327
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRootElement, 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 };
|
|
7195
|
-
/* version: 2.
|
|
7328
|
+
/* version: 2.10.0 */
|