@lwc/engine-core 2.9.0 → 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 +414 -318
- package/dist/engine-core.js +415 -319
- package/package.json +3 -3
- 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/utils.d.ts +2 -0
- package/types/framework/vnodes.d.ts +2 -9
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
|
|
|
@@ -81,6 +81,19 @@ function cloneAndOmitKey(object, keyToOmit) {
|
|
|
81
81
|
|
|
82
82
|
return result;
|
|
83
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;
|
|
96
|
+
}
|
|
84
97
|
|
|
85
98
|
//
|
|
86
99
|
// Primitives
|
|
@@ -2774,6 +2787,45 @@ function getDecoratorsMeta(Ctor) {
|
|
|
2774
2787
|
return isUndefined$1(meta) ? defaultMeta : meta;
|
|
2775
2788
|
}
|
|
2776
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
|
+
*/
|
|
2777
2829
|
const signedTemplateSet = new Set();
|
|
2778
2830
|
function defaultEmptyTemplate() {
|
|
2779
2831
|
return [];
|
|
@@ -2782,12 +2834,27 @@ signedTemplateSet.add(defaultEmptyTemplate);
|
|
|
2782
2834
|
function isTemplateRegistered(tpl) {
|
|
2783
2835
|
return signedTemplateSet.has(tpl);
|
|
2784
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
|
+
}
|
|
2785
2847
|
/**
|
|
2786
2848
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
2787
2849
|
* will prevent this function from being imported by userland code.
|
|
2788
2850
|
*/
|
|
2789
2851
|
|
|
2852
|
+
|
|
2790
2853
|
function registerTemplate(tpl) {
|
|
2854
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2855
|
+
checkTemplateVersionMismatch(tpl);
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2791
2858
|
signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
|
|
2792
2859
|
// assignment of templates easily, without too much transformation
|
|
2793
2860
|
|
|
@@ -3079,20 +3146,6 @@ function rehydrateHotComponent(Ctor) {
|
|
|
3079
3146
|
return canRefreshAllInstances;
|
|
3080
3147
|
}
|
|
3081
3148
|
|
|
3082
|
-
function flattenStylesheets(stylesheets) {
|
|
3083
|
-
const list = [];
|
|
3084
|
-
|
|
3085
|
-
for (const stylesheet of stylesheets) {
|
|
3086
|
-
if (!Array.isArray(stylesheet)) {
|
|
3087
|
-
list.push(stylesheet);
|
|
3088
|
-
} else {
|
|
3089
|
-
list.push(...flattenStylesheets(stylesheet));
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
|
|
3093
|
-
return list;
|
|
3094
|
-
}
|
|
3095
|
-
|
|
3096
3149
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
3097
3150
|
if (process.env.NODE_ENV === 'production') {
|
|
3098
3151
|
// this method should never leak to prod
|
|
@@ -3904,156 +3957,268 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
3904
3957
|
* SPDX-License-Identifier: MIT
|
|
3905
3958
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3906
3959
|
*/
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
move: insertNode,
|
|
3919
|
-
remove: removeNode
|
|
3920
|
-
};
|
|
3921
|
-
const CommentHook = {
|
|
3922
|
-
create: vnode => {
|
|
3923
|
-
const {
|
|
3924
|
-
owner,
|
|
3925
|
-
text
|
|
3926
|
-
} = vnode;
|
|
3927
|
-
const elm = createComment(text);
|
|
3928
|
-
linkNodeToShadow(elm, owner);
|
|
3929
|
-
vnode.elm = elm;
|
|
3930
|
-
},
|
|
3931
|
-
update: updateNodeHook,
|
|
3932
|
-
insert: insertNode,
|
|
3933
|
-
move: insertNode,
|
|
3934
|
-
remove: removeNode
|
|
3935
|
-
}; // insert is called after update, which is used somewhere else (via a module)
|
|
3936
|
-
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
3937
|
-
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
3938
|
-
// which breaks some invariants. For that reason, we have the following for any
|
|
3939
|
-
// Custom Element that is inserted via a template.
|
|
3940
|
-
|
|
3941
|
-
const ElementHook = {
|
|
3942
|
-
create: vnode => {
|
|
3943
|
-
const {
|
|
3944
|
-
sel,
|
|
3945
|
-
owner,
|
|
3946
|
-
data: {
|
|
3947
|
-
svg
|
|
3948
|
-
}
|
|
3949
|
-
} = vnode;
|
|
3950
|
-
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3951
|
-
const elm = createElement(sel, namespace);
|
|
3952
|
-
linkNodeToShadow(elm, owner);
|
|
3953
|
-
fallbackElmHook(elm, vnode);
|
|
3954
|
-
vnode.elm = elm;
|
|
3955
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
3956
|
-
},
|
|
3957
|
-
update: (oldVnode, vnode) => {
|
|
3958
|
-
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
3959
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
3960
|
-
},
|
|
3961
|
-
insert: (vnode, parentNode, referenceNode) => {
|
|
3962
|
-
insertNode(vnode, parentNode, referenceNode);
|
|
3963
|
-
createChildrenHook(vnode);
|
|
3964
|
-
},
|
|
3965
|
-
move: insertNode,
|
|
3966
|
-
remove: (vnode, parentNode) => {
|
|
3967
|
-
removeNode(vnode, parentNode);
|
|
3968
|
-
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;
|
|
3969
3971
|
}
|
|
3970
|
-
};
|
|
3971
|
-
const CustomElementHook = {
|
|
3972
|
-
create: vnode => {
|
|
3973
|
-
const {
|
|
3974
|
-
sel,
|
|
3975
|
-
owner
|
|
3976
|
-
} = vnode;
|
|
3977
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
3978
|
-
/**
|
|
3979
|
-
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3980
|
-
* with a callback as the first argument, we could implement a more advanced
|
|
3981
|
-
* mechanism that only passes that argument if the constructor is known to be
|
|
3982
|
-
* an upgradable custom element.
|
|
3983
|
-
*/
|
|
3984
|
-
|
|
3985
|
-
let vm;
|
|
3986
|
-
const elm = new UpgradableConstructor(elm => {
|
|
3987
|
-
// the custom element from the registry is expecting an upgrade callback
|
|
3988
|
-
vm = createViewModelHook(elm, vnode);
|
|
3989
|
-
});
|
|
3990
|
-
linkNodeToShadow(elm, owner);
|
|
3991
|
-
vnode.elm = elm;
|
|
3992
3972
|
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
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
|
+
}));
|
|
3997
3982
|
}
|
|
3983
|
+
}
|
|
3998
3984
|
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
3985
|
+
switch (n2.type) {
|
|
3986
|
+
case 0
|
|
3987
|
+
/* Text */
|
|
3988
|
+
:
|
|
3989
|
+
patchText(n1, n2);
|
|
3990
|
+
break;
|
|
3991
|
+
|
|
3992
|
+
case 1
|
|
3993
|
+
/* Comment */
|
|
3994
|
+
:
|
|
3995
|
+
patchComment(n1, n2);
|
|
3996
|
+
break;
|
|
4004
3997
|
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
// will happen, but in native, it does allocate the light dom
|
|
3998
|
+
case 2
|
|
3999
|
+
/* Element */
|
|
4000
|
+
:
|
|
4001
|
+
patchElement(n1, n2);
|
|
4002
|
+
break;
|
|
4011
4003
|
|
|
4004
|
+
case 3
|
|
4005
|
+
/* CustomElement */
|
|
4006
|
+
:
|
|
4007
|
+
patchCustomElement(n1, n2);
|
|
4008
|
+
break;
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4012
4011
|
|
|
4013
|
-
|
|
4012
|
+
function mount(node, parent, anchor) {
|
|
4013
|
+
switch (node.type) {
|
|
4014
|
+
case 0
|
|
4015
|
+
/* Text */
|
|
4016
|
+
:
|
|
4017
|
+
mountText(node, parent, anchor);
|
|
4018
|
+
break;
|
|
4014
4019
|
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
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
|
+
}
|
|
4020
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
|
+
}
|
|
4021
4074
|
|
|
4022
|
-
|
|
4075
|
+
function mountElement(vnode, parent, anchor) {
|
|
4076
|
+
const {
|
|
4077
|
+
sel,
|
|
4078
|
+
owner,
|
|
4079
|
+
data: {
|
|
4080
|
+
svg
|
|
4023
4081
|
}
|
|
4024
|
-
}
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
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
|
+
}
|
|
4028
4092
|
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
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);
|
|
4035
4129
|
|
|
4036
|
-
|
|
4130
|
+
if (vm) {
|
|
4131
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4132
|
+
assert.isTrue(vm.state === 0
|
|
4133
|
+
/* created */
|
|
4134
|
+
, `${vm} cannot be recycled.`);
|
|
4037
4135
|
}
|
|
4038
4136
|
|
|
4039
|
-
|
|
4137
|
+
runConnectedCallback(vm);
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
mountVNodes(vnode.children, elm, null);
|
|
4141
|
+
|
|
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);
|
|
4040
4161
|
|
|
4041
|
-
|
|
4042
|
-
|
|
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);
|
|
4043
4175
|
}
|
|
4044
|
-
}
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
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
|
+
}
|
|
4189
|
+
|
|
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
|
+
}
|
|
4049
4212
|
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
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);
|
|
4054
4219
|
}
|
|
4055
4220
|
}
|
|
4056
|
-
}
|
|
4221
|
+
}
|
|
4057
4222
|
|
|
4058
4223
|
function isVNode(vnode) {
|
|
4059
4224
|
return vnode != null;
|
|
@@ -4098,43 +4263,41 @@ function linkNodeToShadow(elm, owner) {
|
|
|
4098
4263
|
}
|
|
4099
4264
|
}
|
|
4100
4265
|
|
|
4101
|
-
function
|
|
4266
|
+
function updateTextContent(vnode) {
|
|
4102
4267
|
const {
|
|
4103
4268
|
elm,
|
|
4104
4269
|
text
|
|
4105
4270
|
} = vnode;
|
|
4106
4271
|
|
|
4107
|
-
if (
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
}
|
|
4272
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4273
|
+
unlockDomMutation();
|
|
4274
|
+
}
|
|
4111
4275
|
|
|
4112
|
-
|
|
4276
|
+
setText(elm, text);
|
|
4113
4277
|
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
}
|
|
4278
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4279
|
+
lockDomMutation();
|
|
4117
4280
|
}
|
|
4118
4281
|
}
|
|
4119
4282
|
|
|
4120
|
-
function insertNode(
|
|
4283
|
+
function insertNode(node, parent, anchor) {
|
|
4121
4284
|
if (process.env.NODE_ENV !== 'production') {
|
|
4122
4285
|
unlockDomMutation();
|
|
4123
4286
|
}
|
|
4124
4287
|
|
|
4125
|
-
insert(
|
|
4288
|
+
insert(node, parent, anchor);
|
|
4126
4289
|
|
|
4127
4290
|
if (process.env.NODE_ENV !== 'production') {
|
|
4128
4291
|
lockDomMutation();
|
|
4129
4292
|
}
|
|
4130
4293
|
}
|
|
4131
4294
|
|
|
4132
|
-
function removeNode(
|
|
4295
|
+
function removeNode(node, parent) {
|
|
4133
4296
|
if (process.env.NODE_ENV !== 'production') {
|
|
4134
4297
|
unlockDomMutation();
|
|
4135
4298
|
}
|
|
4136
4299
|
|
|
4137
|
-
remove(
|
|
4300
|
+
remove(node, parent);
|
|
4138
4301
|
|
|
4139
4302
|
if (process.env.NODE_ENV !== 'production') {
|
|
4140
4303
|
lockDomMutation();
|
|
@@ -4207,13 +4370,6 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4207
4370
|
}
|
|
4208
4371
|
}
|
|
4209
4372
|
|
|
4210
|
-
function patchChildren(parent, oldCh, newCh) {
|
|
4211
|
-
if (hasDynamicChildren(newCh)) {
|
|
4212
|
-
updateDynamicChildren(parent, oldCh, newCh);
|
|
4213
|
-
} else {
|
|
4214
|
-
updateStaticChildren(parent, oldCh, newCh);
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
4373
|
function allocateChildren(vnode, vm) {
|
|
4218
4374
|
// A component with slots will re-render because:
|
|
4219
4375
|
// 1- There is a change of the internal state.
|
|
@@ -4289,40 +4445,6 @@ function createViewModelHook(elm, vnode) {
|
|
|
4289
4445
|
return vm;
|
|
4290
4446
|
}
|
|
4291
4447
|
|
|
4292
|
-
function createChildrenHook(vnode) {
|
|
4293
|
-
const {
|
|
4294
|
-
elm,
|
|
4295
|
-
children
|
|
4296
|
-
} = vnode;
|
|
4297
|
-
|
|
4298
|
-
for (let j = 0; j < children.length; ++j) {
|
|
4299
|
-
const ch = children[j];
|
|
4300
|
-
|
|
4301
|
-
if (ch != null) {
|
|
4302
|
-
ch.hook.create(ch);
|
|
4303
|
-
ch.hook.insert(ch, elm, null);
|
|
4304
|
-
}
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
function removeChildren(vnode) {
|
|
4309
|
-
// this method only needs to search on child vnodes from template
|
|
4310
|
-
// to trigger the remove hook just in case some of those children
|
|
4311
|
-
// are custom elements.
|
|
4312
|
-
const {
|
|
4313
|
-
children,
|
|
4314
|
-
elm
|
|
4315
|
-
} = vnode;
|
|
4316
|
-
|
|
4317
|
-
for (let j = 0, len = children.length; j < len; ++j) {
|
|
4318
|
-
const ch = children[j];
|
|
4319
|
-
|
|
4320
|
-
if (!isNull(ch)) {
|
|
4321
|
-
ch.hook.remove(ch, elm);
|
|
4322
|
-
}
|
|
4323
|
-
}
|
|
4324
|
-
}
|
|
4325
|
-
|
|
4326
4448
|
function allocateInSlot(vm, children) {
|
|
4327
4449
|
var _a;
|
|
4328
4450
|
|
|
@@ -4419,28 +4541,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
4419
4541
|
return map;
|
|
4420
4542
|
}
|
|
4421
4543
|
|
|
4422
|
-
function
|
|
4423
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
4424
|
-
const ch = vnodes[startIdx];
|
|
4425
|
-
|
|
4426
|
-
if (isVNode(ch)) {
|
|
4427
|
-
ch.hook.create(ch);
|
|
4428
|
-
ch.hook.insert(ch, parentElm, before);
|
|
4429
|
-
}
|
|
4430
|
-
}
|
|
4431
|
-
}
|
|
4432
|
-
|
|
4433
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
4434
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
4435
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
4436
|
-
|
|
4437
|
-
if (isVNode(ch)) {
|
|
4438
|
-
ch.hook.remove(ch, parentElm);
|
|
4439
|
-
}
|
|
4440
|
-
}
|
|
4441
|
-
}
|
|
4442
|
-
|
|
4443
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
4544
|
+
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
4444
4545
|
let oldStartIdx = 0;
|
|
4445
4546
|
let newStartIdx = 0;
|
|
4446
4547
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -4466,23 +4567,23 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4466
4567
|
} else if (!isVNode(newEndVnode)) {
|
|
4467
4568
|
newEndVnode = newCh[--newEndIdx];
|
|
4468
4569
|
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4469
|
-
|
|
4570
|
+
patch(oldStartVnode, newStartVnode);
|
|
4470
4571
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
4471
4572
|
newStartVnode = newCh[++newStartIdx];
|
|
4472
4573
|
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4473
|
-
|
|
4574
|
+
patch(oldEndVnode, newEndVnode);
|
|
4474
4575
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
4475
4576
|
newEndVnode = newCh[--newEndIdx];
|
|
4476
4577
|
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4477
4578
|
// Vnode moved right
|
|
4478
|
-
|
|
4479
|
-
|
|
4579
|
+
patch(oldStartVnode, newEndVnode);
|
|
4580
|
+
insertNode(oldStartVnode.elm, parent, nextSibling(oldEndVnode.elm));
|
|
4480
4581
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
4481
4582
|
newEndVnode = newCh[--newEndIdx];
|
|
4482
4583
|
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4483
4584
|
// Vnode moved left
|
|
4484
|
-
|
|
4485
|
-
newStartVnode.
|
|
4585
|
+
patch(oldEndVnode, newStartVnode);
|
|
4586
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
4486
4587
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
4487
4588
|
newStartVnode = newCh[++newStartIdx];
|
|
4488
4589
|
} else {
|
|
@@ -4494,8 +4595,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4494
4595
|
|
|
4495
4596
|
if (isUndefined$1(idxInOld)) {
|
|
4496
4597
|
// New element
|
|
4497
|
-
newStartVnode.
|
|
4498
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
4598
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
4499
4599
|
newStartVnode = newCh[++newStartIdx];
|
|
4500
4600
|
} else {
|
|
4501
4601
|
elmToMove = oldCh[idxInOld];
|
|
@@ -4503,10 +4603,9 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4503
4603
|
if (isVNode(elmToMove)) {
|
|
4504
4604
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4505
4605
|
// New element
|
|
4506
|
-
newStartVnode.
|
|
4507
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
4606
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
4508
4607
|
} else {
|
|
4509
|
-
|
|
4608
|
+
patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
|
|
4510
4609
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4511
4610
|
// so we only care about the `oldCh` object inside this function.
|
|
4512
4611
|
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
@@ -4519,7 +4618,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4519
4618
|
|
|
4520
4619
|
|
|
4521
4620
|
oldCh[idxInOld] = undefined;
|
|
4522
|
-
|
|
4621
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
4523
4622
|
}
|
|
4524
4623
|
}
|
|
4525
4624
|
|
|
@@ -4540,66 +4639,56 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
4540
4639
|
} while (!isVNode(n) && i < newChEnd);
|
|
4541
4640
|
|
|
4542
4641
|
before = isVNode(n) ? n.elm : null;
|
|
4543
|
-
|
|
4642
|
+
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
4544
4643
|
} else {
|
|
4545
|
-
|
|
4644
|
+
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
4546
4645
|
}
|
|
4547
4646
|
}
|
|
4548
4647
|
}
|
|
4549
4648
|
|
|
4550
|
-
function updateStaticChildren(
|
|
4551
|
-
const
|
|
4552
|
-
const
|
|
4649
|
+
function updateStaticChildren(c1, c2, parent) {
|
|
4650
|
+
const c1Length = c1.length;
|
|
4651
|
+
const c2Length = c2.length;
|
|
4553
4652
|
|
|
4554
|
-
if (
|
|
4653
|
+
if (c1Length === 0) {
|
|
4555
4654
|
// the old list is empty, we can directly insert anything new
|
|
4556
|
-
|
|
4655
|
+
mountVNodes(c2, parent, null);
|
|
4557
4656
|
return;
|
|
4558
4657
|
}
|
|
4559
4658
|
|
|
4560
|
-
if (
|
|
4659
|
+
if (c2Length === 0) {
|
|
4561
4660
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4562
4661
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4563
|
-
|
|
4662
|
+
unmountVNodes(c1, parent, true);
|
|
4564
4663
|
return;
|
|
4565
4664
|
} // if the old list is not empty, the new list MUST have the same
|
|
4566
4665
|
// amount of nodes, that's why we call this static children
|
|
4567
4666
|
|
|
4568
4667
|
|
|
4569
|
-
let
|
|
4668
|
+
let anchor = null;
|
|
4570
4669
|
|
|
4571
|
-
for (let i =
|
|
4572
|
-
const
|
|
4573
|
-
const
|
|
4670
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4671
|
+
const n1 = c1[i];
|
|
4672
|
+
const n2 = c2[i];
|
|
4574
4673
|
|
|
4575
|
-
if (
|
|
4576
|
-
if (isVNode(
|
|
4577
|
-
if (isVNode(
|
|
4578
|
-
// both vnodes
|
|
4579
|
-
|
|
4580
|
-
|
|
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;
|
|
4581
4680
|
} else {
|
|
4582
4681
|
// removing the old vnode since the new one is null
|
|
4583
|
-
|
|
4682
|
+
unmount(n1, parent, true);
|
|
4584
4683
|
}
|
|
4585
|
-
} else if (isVNode(
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
4590
|
-
referenceElm = vnode.elm;
|
|
4684
|
+
} else if (isVNode(n2)) {
|
|
4685
|
+
mount(n2, parent, anchor);
|
|
4686
|
+
anchor = n2.elm;
|
|
4591
4687
|
}
|
|
4592
4688
|
}
|
|
4593
4689
|
}
|
|
4594
4690
|
}
|
|
4595
4691
|
|
|
4596
|
-
function patchVnode(oldVnode, vnode) {
|
|
4597
|
-
if (oldVnode !== vnode) {
|
|
4598
|
-
vnode.elm = oldVnode.elm;
|
|
4599
|
-
vnode.hook.update(oldVnode, vnode);
|
|
4600
|
-
}
|
|
4601
|
-
}
|
|
4602
|
-
|
|
4603
4692
|
/*
|
|
4604
4693
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4605
4694
|
* All rights reserved.
|
|
@@ -4649,7 +4738,6 @@ function h(sel, data, children = EmptyArray) {
|
|
|
4649
4738
|
children,
|
|
4650
4739
|
elm,
|
|
4651
4740
|
key,
|
|
4652
|
-
hook: ElementHook,
|
|
4653
4741
|
owner: vmBeingRendered
|
|
4654
4742
|
};
|
|
4655
4743
|
} // [t]ab[i]ndex function
|
|
@@ -4736,7 +4824,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4736
4824
|
const {
|
|
4737
4825
|
key
|
|
4738
4826
|
} = data;
|
|
4739
|
-
let elm;
|
|
4827
|
+
let elm, aChildren, vm;
|
|
4740
4828
|
const vnode = {
|
|
4741
4829
|
type: 3
|
|
4742
4830
|
/* CustomElement */
|
|
@@ -4746,11 +4834,11 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4746
4834
|
children,
|
|
4747
4835
|
elm,
|
|
4748
4836
|
key,
|
|
4749
|
-
hook: CustomElementHook,
|
|
4750
4837
|
ctor: Ctor,
|
|
4751
4838
|
owner: vmBeingRendered,
|
|
4752
|
-
mode: 'open'
|
|
4753
|
-
|
|
4839
|
+
mode: 'open',
|
|
4840
|
+
aChildren,
|
|
4841
|
+
vm
|
|
4754
4842
|
};
|
|
4755
4843
|
addVNodeToChildLWC(vnode);
|
|
4756
4844
|
return vnode;
|
|
@@ -4880,7 +4968,6 @@ function t(text) {
|
|
|
4880
4968
|
text,
|
|
4881
4969
|
elm,
|
|
4882
4970
|
key,
|
|
4883
|
-
hook: TextHook,
|
|
4884
4971
|
owner: getVMBeingRendered()
|
|
4885
4972
|
};
|
|
4886
4973
|
} // [co]mment node
|
|
@@ -4896,7 +4983,6 @@ function co(text) {
|
|
|
4896
4983
|
text,
|
|
4897
4984
|
elm,
|
|
4898
4985
|
key,
|
|
4899
|
-
hook: CommentHook,
|
|
4900
4986
|
owner: getVMBeingRendered()
|
|
4901
4987
|
};
|
|
4902
4988
|
} // [d]ynamic text
|
|
@@ -5747,6 +5833,10 @@ const signedTemplateMap = new Map();
|
|
|
5747
5833
|
function registerComponent(Ctor, {
|
|
5748
5834
|
tmpl
|
|
5749
5835
|
}) {
|
|
5836
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5837
|
+
checkVersionMismatch(Ctor, 'component');
|
|
5838
|
+
}
|
|
5839
|
+
|
|
5750
5840
|
signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
|
|
5751
5841
|
// without too much transformation
|
|
5752
5842
|
|
|
@@ -5863,7 +5953,7 @@ function invokeServiceHook(vm, cbs) {
|
|
|
5863
5953
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5864
5954
|
*/
|
|
5865
5955
|
|
|
5866
|
-
function hydrate
|
|
5956
|
+
function hydrate(vnode, node) {
|
|
5867
5957
|
switch (vnode.type) {
|
|
5868
5958
|
case 0
|
|
5869
5959
|
/* Text */
|
|
@@ -5895,16 +5985,18 @@ function hydrateText(vnode, node) {
|
|
|
5895
5985
|
var _a;
|
|
5896
5986
|
|
|
5897
5987
|
if (process.env.NODE_ENV !== 'production') {
|
|
5898
|
-
|
|
5899
|
-
|
|
5988
|
+
validateNodeType(vnode, node, 3
|
|
5989
|
+
/* TEXT */
|
|
5990
|
+
);
|
|
5991
|
+
const nodeValue = getProperty(node, 'nodeValue');
|
|
5900
5992
|
|
|
5901
|
-
if (
|
|
5993
|
+
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5902
5994
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5903
5995
|
}
|
|
5904
5996
|
} // always set the text value to the one from the vnode.
|
|
5905
5997
|
|
|
5906
5998
|
|
|
5907
|
-
node
|
|
5999
|
+
setText(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5908
6000
|
vnode.elm = node;
|
|
5909
6001
|
}
|
|
5910
6002
|
|
|
@@ -5912,23 +6004,25 @@ function hydrateComment(vnode, node) {
|
|
|
5912
6004
|
var _a;
|
|
5913
6005
|
|
|
5914
6006
|
if (process.env.NODE_ENV !== 'production') {
|
|
5915
|
-
|
|
5916
|
-
|
|
6007
|
+
validateNodeType(vnode, node, 8
|
|
6008
|
+
/* COMMENT */
|
|
6009
|
+
);
|
|
5917
6010
|
|
|
5918
|
-
if (node
|
|
6011
|
+
if (getProperty(node, 'nodeValue') !== vnode.text) {
|
|
5919
6012
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5920
6013
|
}
|
|
5921
6014
|
} // always set the text value to the one from the vnode.
|
|
5922
6015
|
|
|
5923
6016
|
|
|
5924
|
-
node
|
|
6017
|
+
setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5925
6018
|
vnode.elm = node;
|
|
5926
6019
|
}
|
|
5927
6020
|
|
|
5928
6021
|
function hydrateElement(vnode, node) {
|
|
5929
6022
|
if (process.env.NODE_ENV !== 'production') {
|
|
5930
|
-
|
|
5931
|
-
|
|
6023
|
+
validateNodeType(vnode, node, 1
|
|
6024
|
+
/* ELEMENT */
|
|
6025
|
+
);
|
|
5932
6026
|
validateElement(vnode, node);
|
|
5933
6027
|
}
|
|
5934
6028
|
|
|
@@ -5949,13 +6043,13 @@ function hydrateElement(vnode, node) {
|
|
|
5949
6043
|
} = vnode.data;
|
|
5950
6044
|
|
|
5951
6045
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5952
|
-
if (elm
|
|
6046
|
+
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
5953
6047
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
5954
6048
|
vnode.data = Object.assign(Object.assign({}, vnode.data), {
|
|
5955
6049
|
props: cloneAndOmitKey(props, 'innerHTML')
|
|
5956
6050
|
});
|
|
5957
6051
|
} else {
|
|
5958
|
-
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);
|
|
5959
6053
|
}
|
|
5960
6054
|
}
|
|
5961
6055
|
}
|
|
@@ -5963,19 +6057,19 @@ function hydrateElement(vnode, node) {
|
|
|
5963
6057
|
patchElementPropsAndAttrs(vnode);
|
|
5964
6058
|
|
|
5965
6059
|
if (!isDomManual) {
|
|
5966
|
-
hydrateChildren(vnode.elm
|
|
6060
|
+
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vnode.owner);
|
|
5967
6061
|
}
|
|
5968
6062
|
}
|
|
5969
6063
|
|
|
5970
6064
|
function hydrateCustomElement(vnode, node) {
|
|
5971
6065
|
if (process.env.NODE_ENV !== 'production') {
|
|
5972
|
-
|
|
5973
|
-
|
|
6066
|
+
validateNodeType(vnode, node, 1
|
|
6067
|
+
/* ELEMENT */
|
|
6068
|
+
);
|
|
5974
6069
|
validateElement(vnode, node);
|
|
5975
6070
|
}
|
|
5976
6071
|
|
|
5977
6072
|
const elm = node;
|
|
5978
|
-
vnode.elm = elm;
|
|
5979
6073
|
const {
|
|
5980
6074
|
sel,
|
|
5981
6075
|
mode,
|
|
@@ -5987,6 +6081,8 @@ function hydrateCustomElement(vnode, node) {
|
|
|
5987
6081
|
owner,
|
|
5988
6082
|
tagName: sel
|
|
5989
6083
|
});
|
|
6084
|
+
vnode.elm = elm;
|
|
6085
|
+
vnode.vm = vm;
|
|
5990
6086
|
allocateChildren(vnode, vm);
|
|
5991
6087
|
patchElementPropsAndAttrs(vnode); // Insert hook section:
|
|
5992
6088
|
|
|
@@ -6003,7 +6099,7 @@ function hydrateCustomElement(vnode, node) {
|
|
|
6003
6099
|
) {
|
|
6004
6100
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6005
6101
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6006
|
-
hydrateChildren(vnode.elm
|
|
6102
|
+
hydrateChildren(getChildNodes(vnode.elm), vnode.children, vm);
|
|
6007
6103
|
}
|
|
6008
6104
|
|
|
6009
6105
|
hydrateVM(vm);
|
|
@@ -6026,7 +6122,7 @@ function hydrateChildren(elmChildren, children, vm) {
|
|
|
6026
6122
|
|
|
6027
6123
|
if (!isNull(childVnode)) {
|
|
6028
6124
|
const childNode = elmChildren[childNodeIndex];
|
|
6029
|
-
hydrate
|
|
6125
|
+
hydrate(childVnode, childNode);
|
|
6030
6126
|
childNodeIndex++;
|
|
6031
6127
|
}
|
|
6032
6128
|
}
|
|
@@ -6042,15 +6138,15 @@ function throwHydrationError() {
|
|
|
6042
6138
|
}
|
|
6043
6139
|
|
|
6044
6140
|
function validateNodeType(vnode, node, nodeType) {
|
|
6045
|
-
if (node
|
|
6141
|
+
if (getProperty(node, 'nodeType') !== nodeType) {
|
|
6046
6142
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6047
6143
|
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
6048
6144
|
}
|
|
6049
6145
|
}
|
|
6050
6146
|
|
|
6051
6147
|
function validateElement(vnode, elm) {
|
|
6052
|
-
if (vnode.sel.toLowerCase() !== elm
|
|
6053
|
-
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);
|
|
6054
6150
|
throwHydrationError();
|
|
6055
6151
|
}
|
|
6056
6152
|
|
|
@@ -6077,7 +6173,7 @@ function validateAttrs(vnode, elm) {
|
|
|
6077
6173
|
const elmAttrValue = getAttribute(elm, attrName);
|
|
6078
6174
|
|
|
6079
6175
|
if (String(attrValue) !== elmAttrValue) {
|
|
6080
|
-
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);
|
|
6081
6177
|
nodesAreCompatible = false;
|
|
6082
6178
|
}
|
|
6083
6179
|
}
|
|
@@ -6095,7 +6191,7 @@ function validateClassAttr(vnode, elm) {
|
|
|
6095
6191
|
let nodesAreCompatible = true;
|
|
6096
6192
|
let vnodeClassName;
|
|
6097
6193
|
|
|
6098
|
-
if (!isUndefined$1(className) && String(className) !== elm
|
|
6194
|
+
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
6099
6195
|
// className is used when class is bound to an expr.
|
|
6100
6196
|
nodesAreCompatible = false;
|
|
6101
6197
|
vnodeClassName = className;
|
|
@@ -6120,7 +6216,7 @@ function validateClassAttr(vnode, elm) {
|
|
|
6120
6216
|
}
|
|
6121
6217
|
|
|
6122
6218
|
if (!nodesAreCompatible) {
|
|
6123
|
-
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);
|
|
6124
6220
|
}
|
|
6125
6221
|
|
|
6126
6222
|
return nodesAreCompatible;
|
|
@@ -6167,7 +6263,7 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6167
6263
|
|
|
6168
6264
|
if (!nodesAreCompatible) {
|
|
6169
6265
|
// style is used when class is bound to an expr.
|
|
6170
|
-
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);
|
|
6171
6267
|
}
|
|
6172
6268
|
|
|
6173
6269
|
return nodesAreCompatible;
|
|
@@ -6231,7 +6327,19 @@ function appendVM(vm) {
|
|
|
6231
6327
|
rehydrate(vm);
|
|
6232
6328
|
}
|
|
6233
6329
|
function hydrateVM(vm) {
|
|
6234
|
-
|
|
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
|
+
}
|
|
6235
6343
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6236
6344
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6237
6345
|
|
|
@@ -6381,7 +6489,11 @@ function computeShadowMode(vm) {
|
|
|
6381
6489
|
/* Native */
|
|
6382
6490
|
;
|
|
6383
6491
|
} else if (isNativeShadowDefined) {
|
|
6384
|
-
if (
|
|
6492
|
+
if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
|
|
6493
|
+
shadowMode = 1
|
|
6494
|
+
/* Synthetic */
|
|
6495
|
+
;
|
|
6496
|
+
} else if (def.shadowSupportMode === "any"
|
|
6385
6497
|
/* Any */
|
|
6386
6498
|
) {
|
|
6387
6499
|
shadowMode = 0
|
|
@@ -6459,22 +6571,6 @@ function rehydrate(vm) {
|
|
|
6459
6571
|
}
|
|
6460
6572
|
}
|
|
6461
6573
|
|
|
6462
|
-
function hydrate(vm) {
|
|
6463
|
-
if (isTrue(vm.isDirty)) {
|
|
6464
|
-
// manually diffing/patching here.
|
|
6465
|
-
// This routine is:
|
|
6466
|
-
// patchShadowRoot(vm, children);
|
|
6467
|
-
// -> addVnodes.
|
|
6468
|
-
const children = renderComponent(vm);
|
|
6469
|
-
vm.children = children;
|
|
6470
|
-
const vmChildren = vm.renderMode === 0
|
|
6471
|
-
/* Light */
|
|
6472
|
-
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
6473
|
-
hydrateChildren(vmChildren, children, vm);
|
|
6474
|
-
runRenderedCallback(vm);
|
|
6475
|
-
}
|
|
6476
|
-
}
|
|
6477
|
-
|
|
6478
6574
|
function patchShadowRoot(vm, newCh) {
|
|
6479
6575
|
const {
|
|
6480
6576
|
renderRoot,
|
|
@@ -6494,7 +6590,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
6494
6590
|
, vm);
|
|
6495
6591
|
}, () => {
|
|
6496
6592
|
// job
|
|
6497
|
-
patchChildren(
|
|
6593
|
+
patchChildren(oldCh, newCh, renderRoot);
|
|
6498
6594
|
}, () => {
|
|
6499
6595
|
// post
|
|
6500
6596
|
logOperationEnd(2
|
|
@@ -7229,4 +7325,4 @@ function setHooks(hooks) {
|
|
|
7229
7325
|
}
|
|
7230
7326
|
|
|
7231
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 };
|
|
7232
|
-
/* version: 2.
|
|
7328
|
+
/* version: 2.10.0 */
|