@lwc/engine-core 2.29.0 → 2.30.1
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 +221 -638
- package/dist/engine-core.js +221 -636
- package/package.json +3 -3
- package/types/framework/vm.d.ts +3 -0
package/dist/engine-core.cjs.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
4
|
var features = require('@lwc/features');
|
|
7
5
|
var shared = require('@lwc/shared');
|
|
8
6
|
|
|
@@ -12,16 +10,14 @@ var shared = require('@lwc/shared');
|
|
|
12
10
|
* SPDX-License-Identifier: MIT
|
|
13
11
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
14
12
|
*/
|
|
13
|
+
// Only used in LWC's Karma tests
|
|
15
14
|
// @ts-ignore
|
|
16
|
-
|
|
17
15
|
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
18
16
|
window.addEventListener('test-dummy-flag', () => {
|
|
19
17
|
let hasFlag = false;
|
|
20
|
-
|
|
21
18
|
if (features.lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
22
19
|
hasFlag = true;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
26
22
|
detail: {
|
|
27
23
|
package: '@lwc/engine-core',
|
|
@@ -1884,39 +1880,31 @@ function api$1() {
|
|
|
1884
1880
|
if (process.env.NODE_ENV !== 'production') {
|
|
1885
1881
|
shared.assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
1886
1882
|
}
|
|
1887
|
-
|
|
1888
1883
|
throw new Error();
|
|
1889
1884
|
}
|
|
1890
1885
|
function createPublicPropertyDescriptor(key) {
|
|
1891
1886
|
return {
|
|
1892
1887
|
get() {
|
|
1893
1888
|
const vm = getAssociatedVM(this);
|
|
1894
|
-
|
|
1895
1889
|
if (isBeingConstructed(vm)) {
|
|
1896
1890
|
if (process.env.NODE_ENV !== 'production') {
|
|
1897
1891
|
logError(`Can’t read the value of property \`${shared.toString(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
1898
1892
|
}
|
|
1899
|
-
|
|
1900
1893
|
return;
|
|
1901
1894
|
}
|
|
1902
|
-
|
|
1903
1895
|
componentValueObserved(vm, key);
|
|
1904
1896
|
return vm.cmpProps[key];
|
|
1905
1897
|
},
|
|
1906
|
-
|
|
1907
1898
|
set(newValue) {
|
|
1908
1899
|
const vm = getAssociatedVM(this);
|
|
1909
|
-
|
|
1910
1900
|
if (process.env.NODE_ENV !== 'production') {
|
|
1911
1901
|
const vmBeingRendered = getVMBeingRendered();
|
|
1912
1902
|
shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1913
1903
|
shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1914
1904
|
}
|
|
1915
|
-
|
|
1916
1905
|
vm.cmpProps[key] = newValue;
|
|
1917
1906
|
componentValueMutated(vm, key);
|
|
1918
1907
|
},
|
|
1919
|
-
|
|
1920
1908
|
enumerable: true,
|
|
1921
1909
|
configurable: true
|
|
1922
1910
|
};
|
|
@@ -1928,46 +1916,37 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1928
1916
|
enumerable,
|
|
1929
1917
|
configurable
|
|
1930
1918
|
} = descriptor;
|
|
1931
|
-
|
|
1932
1919
|
if (!shared.isFunction(get)) {
|
|
1933
1920
|
if (process.env.NODE_ENV !== 'production') {
|
|
1934
1921
|
shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
|
|
1935
1922
|
}
|
|
1936
|
-
|
|
1937
1923
|
throw new Error();
|
|
1938
1924
|
}
|
|
1939
|
-
|
|
1940
1925
|
return {
|
|
1941
1926
|
get() {
|
|
1942
1927
|
if (process.env.NODE_ENV !== 'production') {
|
|
1943
1928
|
// Assert that the this value is an actual Component with an associated VM.
|
|
1944
1929
|
getAssociatedVM(this);
|
|
1945
1930
|
}
|
|
1946
|
-
|
|
1947
1931
|
return get.call(this);
|
|
1948
1932
|
},
|
|
1949
|
-
|
|
1950
1933
|
set(newValue) {
|
|
1951
1934
|
const vm = getAssociatedVM(this);
|
|
1952
|
-
|
|
1953
1935
|
if (process.env.NODE_ENV !== 'production') {
|
|
1954
1936
|
const vmBeingRendered = getVMBeingRendered();
|
|
1955
1937
|
shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1956
1938
|
shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1957
1939
|
}
|
|
1958
|
-
|
|
1959
1940
|
if (set) {
|
|
1960
1941
|
if (features.lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
1961
1942
|
let ro = vm.oar[key];
|
|
1962
|
-
|
|
1963
1943
|
if (shared.isUndefined(ro)) {
|
|
1964
1944
|
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
1965
|
-
}
|
|
1945
|
+
}
|
|
1946
|
+
// every time we invoke this setter from outside (through this wrapper setter)
|
|
1966
1947
|
// we should reset the value and then debounce just in case there is a pending
|
|
1967
1948
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
1968
1949
|
// from outside.
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
1950
|
ro.reset(newValue);
|
|
1972
1951
|
ro.observe(() => {
|
|
1973
1952
|
set.call(this, newValue);
|
|
@@ -1979,7 +1958,6 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1979
1958
|
shared.assert.fail(`Invalid attempt to set a new value for property ${shared.toString(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
1980
1959
|
}
|
|
1981
1960
|
},
|
|
1982
|
-
|
|
1983
1961
|
enumerable,
|
|
1984
1962
|
configurable
|
|
1985
1963
|
};
|
|
@@ -2944,11 +2922,9 @@ function getComponentDef(Ctor) {
|
|
|
2944
2922
|
* SPDX-License-Identifier: MIT
|
|
2945
2923
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2946
2924
|
*/
|
|
2947
|
-
|
|
2948
2925
|
function makeHostToken(token) {
|
|
2949
2926
|
return `${token}-host`;
|
|
2950
2927
|
}
|
|
2951
|
-
|
|
2952
2928
|
function createInlineStyleVNode(content) {
|
|
2953
2929
|
return api.h('style', {
|
|
2954
2930
|
key: 'style',
|
|
@@ -2957,7 +2933,6 @@ function createInlineStyleVNode(content) {
|
|
|
2957
2933
|
}
|
|
2958
2934
|
}, [api.t(content)]);
|
|
2959
2935
|
}
|
|
2960
|
-
|
|
2961
2936
|
function updateStylesheetToken(vm, template) {
|
|
2962
2937
|
const {
|
|
2963
2938
|
elm,
|
|
@@ -2974,112 +2949,81 @@ function updateStylesheetToken(vm, template) {
|
|
|
2974
2949
|
stylesheets: newStylesheets,
|
|
2975
2950
|
stylesheetToken: newStylesheetToken
|
|
2976
2951
|
} = template;
|
|
2977
|
-
const isSyntheticShadow = renderMode === 1
|
|
2978
|
-
/* RenderMode.Shadow */
|
|
2979
|
-
&& shadowMode === 1
|
|
2980
|
-
/* ShadowMode.Synthetic */
|
|
2981
|
-
;
|
|
2952
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
2982
2953
|
const {
|
|
2983
2954
|
hasScopedStyles
|
|
2984
2955
|
} = context;
|
|
2985
2956
|
let newToken;
|
|
2986
2957
|
let newHasTokenInClass;
|
|
2987
|
-
let newHasTokenInAttribute;
|
|
2988
|
-
|
|
2958
|
+
let newHasTokenInAttribute;
|
|
2959
|
+
// Reset the styling token applied to the host element.
|
|
2989
2960
|
const {
|
|
2990
2961
|
stylesheetToken: oldToken,
|
|
2991
2962
|
hasTokenInClass: oldHasTokenInClass,
|
|
2992
2963
|
hasTokenInAttribute: oldHasTokenInAttribute
|
|
2993
2964
|
} = context;
|
|
2994
|
-
|
|
2995
2965
|
if (!shared.isUndefined(oldToken)) {
|
|
2996
2966
|
if (oldHasTokenInClass) {
|
|
2997
2967
|
getClassList(elm).remove(makeHostToken(oldToken));
|
|
2998
2968
|
}
|
|
2999
|
-
|
|
3000
2969
|
if (oldHasTokenInAttribute) {
|
|
3001
2970
|
removeAttribute(elm, makeHostToken(oldToken));
|
|
3002
2971
|
}
|
|
3003
|
-
}
|
|
2972
|
+
}
|
|
2973
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
3004
2974
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
2975
|
if (!shared.isUndefined(newStylesheets) && newStylesheets.length !== 0) {
|
|
3008
2976
|
newToken = newStylesheetToken;
|
|
3009
|
-
}
|
|
3010
|
-
|
|
3011
|
-
|
|
2977
|
+
}
|
|
2978
|
+
// Set the new styling token on the host element
|
|
3012
2979
|
if (!shared.isUndefined(newToken)) {
|
|
3013
2980
|
if (hasScopedStyles) {
|
|
3014
2981
|
getClassList(elm).add(makeHostToken(newToken));
|
|
3015
2982
|
newHasTokenInClass = true;
|
|
3016
2983
|
}
|
|
3017
|
-
|
|
3018
2984
|
if (isSyntheticShadow) {
|
|
3019
2985
|
setAttribute(elm, makeHostToken(newToken), '');
|
|
3020
2986
|
newHasTokenInAttribute = true;
|
|
3021
2987
|
}
|
|
3022
|
-
}
|
|
3023
|
-
|
|
3024
|
-
|
|
2988
|
+
}
|
|
2989
|
+
// Update the styling tokens present on the context object.
|
|
3025
2990
|
context.stylesheetToken = newToken;
|
|
3026
2991
|
context.hasTokenInClass = newHasTokenInClass;
|
|
3027
2992
|
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3028
2993
|
}
|
|
3029
|
-
|
|
3030
2994
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3031
2995
|
const content = [];
|
|
3032
2996
|
let root;
|
|
3033
|
-
|
|
3034
2997
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3035
2998
|
let stylesheet = stylesheets[i];
|
|
3036
|
-
|
|
3037
2999
|
if (shared.isArray(stylesheet)) {
|
|
3038
3000
|
shared.ArrayPush.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3039
3001
|
} else {
|
|
3040
3002
|
if (process.env.NODE_ENV !== 'production') {
|
|
3041
3003
|
// Check for compiler version mismatch in dev mode only
|
|
3042
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3004
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3005
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3043
3006
|
// the component instance might be attempting to use an old version of
|
|
3044
3007
|
// the stylesheet, while internally, we have a replacement for it.
|
|
3045
|
-
|
|
3046
3008
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3047
3009
|
}
|
|
3048
|
-
|
|
3049
3010
|
const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS];
|
|
3050
|
-
|
|
3051
3011
|
if (features.lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
|
|
3052
|
-
if (!isScopedCss && vm.renderMode === 0
|
|
3053
|
-
/* RenderMode.Light */
|
|
3054
|
-
) {
|
|
3012
|
+
if (!isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
|
3055
3013
|
logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
|
|
3056
3014
|
continue;
|
|
3057
3015
|
}
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
/* ShadowMode.Synthetic */
|
|
3063
|
-
&& vm.renderMode === 1
|
|
3064
|
-
/* RenderMode.Shadow */
|
|
3065
|
-
? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3016
|
+
}
|
|
3017
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3018
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
|
3019
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3066
3020
|
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
/* RenderMode.Light */
|
|
3070
|
-
? !isScopedCss : vm.shadowMode === 0
|
|
3071
|
-
/* ShadowMode.Native */
|
|
3072
|
-
; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3021
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3022
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3073
3023
|
// we use an attribute selector on the host to simulate :dir().
|
|
3074
|
-
|
|
3075
3024
|
let useNativeDirPseudoclass;
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
/* RenderMode.Shadow */
|
|
3079
|
-
) {
|
|
3080
|
-
useNativeDirPseudoclass = vm.shadowMode === 0
|
|
3081
|
-
/* ShadowMode.Native */
|
|
3082
|
-
;
|
|
3025
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3026
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3083
3027
|
} else {
|
|
3084
3028
|
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3085
3029
|
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
@@ -3087,48 +3031,36 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
|
3087
3031
|
// Only calculate the root once as necessary
|
|
3088
3032
|
root = getNearestShadowComponent(vm);
|
|
3089
3033
|
}
|
|
3090
|
-
|
|
3091
|
-
useNativeDirPseudoclass = shared.isNull(root) || root.shadowMode === 0
|
|
3092
|
-
/* ShadowMode.Native */
|
|
3093
|
-
;
|
|
3034
|
+
useNativeDirPseudoclass = shared.isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3094
3035
|
}
|
|
3095
3036
|
|
|
3096
3037
|
shared.ArrayPush.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3097
3038
|
}
|
|
3098
3039
|
}
|
|
3099
|
-
|
|
3100
3040
|
return content;
|
|
3101
3041
|
}
|
|
3102
|
-
|
|
3103
3042
|
function getStylesheetsContent(vm, template) {
|
|
3104
3043
|
const {
|
|
3105
3044
|
stylesheets,
|
|
3106
3045
|
stylesheetToken
|
|
3107
3046
|
} = template;
|
|
3108
3047
|
let content = [];
|
|
3109
|
-
|
|
3110
3048
|
if (!shared.isUndefined(stylesheets) && stylesheets.length !== 0) {
|
|
3111
3049
|
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3112
3050
|
}
|
|
3113
|
-
|
|
3114
3051
|
return content;
|
|
3115
|
-
}
|
|
3052
|
+
}
|
|
3053
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3116
3054
|
// perf testing has not shown it to be a huge improvement yet:
|
|
3117
3055
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3118
|
-
|
|
3119
3056
|
function getNearestShadowComponent(vm) {
|
|
3120
3057
|
let owner = vm;
|
|
3121
|
-
|
|
3122
3058
|
while (!shared.isNull(owner)) {
|
|
3123
|
-
if (owner.renderMode === 1
|
|
3124
|
-
/* RenderMode.Shadow */
|
|
3125
|
-
) {
|
|
3059
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3126
3060
|
return owner;
|
|
3127
3061
|
}
|
|
3128
|
-
|
|
3129
3062
|
owner = owner.owner;
|
|
3130
3063
|
}
|
|
3131
|
-
|
|
3132
3064
|
return owner;
|
|
3133
3065
|
}
|
|
3134
3066
|
/**
|
|
@@ -3136,8 +3068,6 @@ function getNearestShadowComponent(vm) {
|
|
|
3136
3068
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3137
3069
|
* it returns null.
|
|
3138
3070
|
*/
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
3071
|
function getScopeTokenClass(owner) {
|
|
3142
3072
|
const {
|
|
3143
3073
|
cmpTemplate,
|
|
@@ -3151,7 +3081,6 @@ function getScopeTokenClass(owner) {
|
|
|
3151
3081
|
*
|
|
3152
3082
|
* A host style token is applied to the component if scoped styles are used.
|
|
3153
3083
|
*/
|
|
3154
|
-
|
|
3155
3084
|
function getStylesheetTokenHost(vnode) {
|
|
3156
3085
|
const {
|
|
3157
3086
|
template
|
|
@@ -3161,21 +3090,15 @@ function getStylesheetTokenHost(vnode) {
|
|
|
3161
3090
|
} = template;
|
|
3162
3091
|
return !shared.isUndefined(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3163
3092
|
}
|
|
3164
|
-
|
|
3165
3093
|
function getNearestNativeShadowComponent(vm) {
|
|
3166
3094
|
const owner = getNearestShadowComponent(vm);
|
|
3167
|
-
|
|
3168
|
-
if (!shared.isNull(owner) && owner.shadowMode === 1
|
|
3169
|
-
/* ShadowMode.Synthetic */
|
|
3170
|
-
) {
|
|
3095
|
+
if (!shared.isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3171
3096
|
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3172
3097
|
// synthetic, we know we won't find a native component if we go any further.
|
|
3173
3098
|
return null;
|
|
3174
3099
|
}
|
|
3175
|
-
|
|
3176
3100
|
return owner;
|
|
3177
3101
|
}
|
|
3178
|
-
|
|
3179
3102
|
function createStylesheet(vm, stylesheets) {
|
|
3180
3103
|
const {
|
|
3181
3104
|
renderMode,
|
|
@@ -3184,12 +3107,7 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3184
3107
|
insertStylesheet
|
|
3185
3108
|
}
|
|
3186
3109
|
} = vm;
|
|
3187
|
-
|
|
3188
|
-
if (renderMode === 1
|
|
3189
|
-
/* RenderMode.Shadow */
|
|
3190
|
-
&& shadowMode === 1
|
|
3191
|
-
/* ShadowMode.Synthetic */
|
|
3192
|
-
) {
|
|
3110
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3193
3111
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3194
3112
|
insertStylesheet(stylesheets[i]);
|
|
3195
3113
|
}
|
|
@@ -3201,15 +3119,13 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3201
3119
|
return shared.ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3202
3120
|
} else {
|
|
3203
3121
|
// native shadow or light DOM, DOM renderer
|
|
3204
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
3205
|
-
|
|
3122
|
+
const root = getNearestNativeShadowComponent(vm);
|
|
3123
|
+
// null root means a global style
|
|
3206
3124
|
const target = shared.isNull(root) ? undefined : root.shadowRoot;
|
|
3207
|
-
|
|
3208
3125
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3209
3126
|
insertStylesheet(stylesheets[i], target);
|
|
3210
3127
|
}
|
|
3211
3128
|
}
|
|
3212
|
-
|
|
3213
3129
|
return null;
|
|
3214
3130
|
}
|
|
3215
3131
|
|
|
@@ -3495,14 +3411,11 @@ function patchChildren(c1, c2, parent, renderer) {
|
|
|
3495
3411
|
updateStaticChildren(c1, c2, parent, renderer);
|
|
3496
3412
|
}
|
|
3497
3413
|
}
|
|
3498
|
-
|
|
3499
3414
|
function patch(n1, n2, parent, renderer) {
|
|
3500
3415
|
var _a, _b;
|
|
3501
|
-
|
|
3502
3416
|
if (n1 === n2) {
|
|
3503
3417
|
return;
|
|
3504
3418
|
}
|
|
3505
|
-
|
|
3506
3419
|
if (process.env.NODE_ENV !== 'production') {
|
|
3507
3420
|
if (!isSameVnode(n1, n2)) {
|
|
3508
3421
|
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
@@ -3514,103 +3427,63 @@ function patch(n1, n2, parent, renderer) {
|
|
|
3514
3427
|
}));
|
|
3515
3428
|
}
|
|
3516
3429
|
}
|
|
3517
|
-
|
|
3518
3430
|
switch (n2.type) {
|
|
3519
|
-
case 0
|
|
3520
|
-
/* VNodeType.Text */
|
|
3521
|
-
:
|
|
3431
|
+
case 0 /* VNodeType.Text */:
|
|
3522
3432
|
// VText has no special capability, fallback to the owner's renderer
|
|
3523
3433
|
patchText(n1, n2, renderer);
|
|
3524
3434
|
break;
|
|
3525
|
-
|
|
3526
|
-
case 1
|
|
3527
|
-
/* VNodeType.Comment */
|
|
3528
|
-
:
|
|
3435
|
+
case 1 /* VNodeType.Comment */:
|
|
3529
3436
|
// VComment has no special capability, fallback to the owner's renderer
|
|
3530
3437
|
patchComment(n1, n2, renderer);
|
|
3531
3438
|
break;
|
|
3532
|
-
|
|
3533
|
-
case 4
|
|
3534
|
-
/* VNodeType.Static */
|
|
3535
|
-
:
|
|
3439
|
+
case 4 /* VNodeType.Static */:
|
|
3536
3440
|
n2.elm = n1.elm;
|
|
3537
3441
|
break;
|
|
3538
|
-
|
|
3539
|
-
case 5
|
|
3540
|
-
/* VNodeType.Fragment */
|
|
3541
|
-
:
|
|
3442
|
+
case 5 /* VNodeType.Fragment */:
|
|
3542
3443
|
patchFragment(n1, n2, parent, renderer);
|
|
3543
3444
|
break;
|
|
3544
|
-
|
|
3545
|
-
case 2
|
|
3546
|
-
/* VNodeType.Element */
|
|
3547
|
-
:
|
|
3445
|
+
case 2 /* VNodeType.Element */:
|
|
3548
3446
|
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3549
3447
|
break;
|
|
3550
|
-
|
|
3551
|
-
case 3
|
|
3552
|
-
/* VNodeType.CustomElement */
|
|
3553
|
-
:
|
|
3448
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3554
3449
|
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3555
3450
|
break;
|
|
3556
3451
|
}
|
|
3557
3452
|
}
|
|
3558
|
-
|
|
3559
3453
|
function mount(node, parent, renderer, anchor) {
|
|
3560
3454
|
var _a, _b;
|
|
3561
|
-
|
|
3562
3455
|
switch (node.type) {
|
|
3563
|
-
case 0
|
|
3564
|
-
/* VNodeType.Text */
|
|
3565
|
-
:
|
|
3456
|
+
case 0 /* VNodeType.Text */:
|
|
3566
3457
|
// VText has no special capability, fallback to the owner's renderer
|
|
3567
3458
|
mountText(node, parent, anchor, renderer);
|
|
3568
3459
|
break;
|
|
3569
|
-
|
|
3570
|
-
case 1
|
|
3571
|
-
/* VNodeType.Comment */
|
|
3572
|
-
:
|
|
3460
|
+
case 1 /* VNodeType.Comment */:
|
|
3573
3461
|
// VComment has no special capability, fallback to the owner's renderer
|
|
3574
3462
|
mountComment(node, parent, anchor, renderer);
|
|
3575
3463
|
break;
|
|
3576
|
-
|
|
3577
|
-
case 4
|
|
3578
|
-
/* VNodeType.Static */
|
|
3579
|
-
:
|
|
3464
|
+
case 4 /* VNodeType.Static */:
|
|
3580
3465
|
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3581
3466
|
mountStatic(node, parent, anchor, renderer);
|
|
3582
3467
|
break;
|
|
3583
|
-
|
|
3584
|
-
case 5
|
|
3585
|
-
/* VNodeType.Fragment */
|
|
3586
|
-
:
|
|
3468
|
+
case 5 /* VNodeType.Fragment */:
|
|
3587
3469
|
mountFragment(node, parent, anchor, renderer);
|
|
3588
3470
|
break;
|
|
3589
|
-
|
|
3590
|
-
case 2
|
|
3591
|
-
/* VNodeType.Element */
|
|
3592
|
-
:
|
|
3471
|
+
case 2 /* VNodeType.Element */:
|
|
3593
3472
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3594
3473
|
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3595
3474
|
break;
|
|
3596
|
-
|
|
3597
|
-
case 3
|
|
3598
|
-
/* VNodeType.CustomElement */
|
|
3599
|
-
:
|
|
3475
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3600
3476
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3601
3477
|
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3602
3478
|
break;
|
|
3603
3479
|
}
|
|
3604
3480
|
}
|
|
3605
|
-
|
|
3606
3481
|
function patchText(n1, n2, renderer) {
|
|
3607
3482
|
n2.elm = n1.elm;
|
|
3608
|
-
|
|
3609
3483
|
if (n2.text !== n1.text) {
|
|
3610
3484
|
updateTextContent(n2, renderer);
|
|
3611
3485
|
}
|
|
3612
3486
|
}
|
|
3613
|
-
|
|
3614
3487
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3615
3488
|
const {
|
|
3616
3489
|
owner
|
|
@@ -3622,16 +3495,14 @@ function mountText(vnode, parent, anchor, renderer) {
|
|
|
3622
3495
|
linkNodeToShadow(textNode, owner, renderer);
|
|
3623
3496
|
insertNode(textNode, parent, anchor, renderer);
|
|
3624
3497
|
}
|
|
3625
|
-
|
|
3626
3498
|
function patchComment(n1, n2, renderer) {
|
|
3627
|
-
n2.elm = n1.elm;
|
|
3499
|
+
n2.elm = n1.elm;
|
|
3500
|
+
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3628
3501
|
// it is the case today.
|
|
3629
|
-
|
|
3630
3502
|
if (n2.text !== n1.text) {
|
|
3631
3503
|
updateTextContent(n2, renderer);
|
|
3632
3504
|
}
|
|
3633
3505
|
}
|
|
3634
|
-
|
|
3635
3506
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3636
3507
|
const {
|
|
3637
3508
|
owner
|
|
@@ -3643,32 +3514,27 @@ function mountComment(vnode, parent, anchor, renderer) {
|
|
|
3643
3514
|
linkNodeToShadow(commentNode, owner, renderer);
|
|
3644
3515
|
insertNode(commentNode, parent, anchor, renderer);
|
|
3645
3516
|
}
|
|
3646
|
-
|
|
3647
3517
|
function mountFragment(vnode, parent, anchor, renderer) {
|
|
3648
3518
|
const {
|
|
3649
3519
|
children
|
|
3650
3520
|
} = vnode;
|
|
3651
|
-
mountVNodes(children, parent, renderer, anchor);
|
|
3652
|
-
|
|
3521
|
+
mountVNodes(children, parent, renderer, anchor);
|
|
3522
|
+
// children of a fragment will always have at least the two delimiters.
|
|
3653
3523
|
vnode.elm = children[children.length - 1].elm;
|
|
3654
3524
|
}
|
|
3655
|
-
|
|
3656
3525
|
function patchFragment(n1, n2, parent, renderer) {
|
|
3657
3526
|
const {
|
|
3658
3527
|
children,
|
|
3659
3528
|
stable
|
|
3660
3529
|
} = n2;
|
|
3661
|
-
|
|
3662
3530
|
if (stable) {
|
|
3663
3531
|
updateStaticChildren(n1.children, children, parent, renderer);
|
|
3664
3532
|
} else {
|
|
3665
3533
|
updateDynamicChildren(n1.children, children, parent, renderer);
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3668
|
-
|
|
3534
|
+
}
|
|
3535
|
+
// Note: not reusing n1.elm, because during patching, it may be patched with another text node.
|
|
3669
3536
|
n2.elm = children[children.length - 1].elm;
|
|
3670
3537
|
}
|
|
3671
|
-
|
|
3672
3538
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3673
3539
|
const {
|
|
3674
3540
|
sel,
|
|
@@ -3690,13 +3556,11 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
3690
3556
|
insertNode(elm, parent, anchor, renderer);
|
|
3691
3557
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
3692
3558
|
}
|
|
3693
|
-
|
|
3694
3559
|
function patchElement(n1, n2, renderer) {
|
|
3695
3560
|
const elm = n2.elm = n1.elm;
|
|
3696
3561
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3697
3562
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3698
3563
|
}
|
|
3699
|
-
|
|
3700
3564
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3701
3565
|
const {
|
|
3702
3566
|
owner
|
|
@@ -3707,26 +3571,19 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
3707
3571
|
} = renderer;
|
|
3708
3572
|
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
3709
3573
|
linkNodeToShadow(elm, owner, renderer);
|
|
3710
|
-
applyElementRestrictions(elm, vnode);
|
|
3711
|
-
|
|
3574
|
+
applyElementRestrictions(elm, vnode);
|
|
3575
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3712
3576
|
const {
|
|
3713
3577
|
renderMode,
|
|
3714
3578
|
shadowMode
|
|
3715
3579
|
} = owner;
|
|
3716
|
-
|
|
3717
3580
|
if (isSyntheticShadowDefined) {
|
|
3718
|
-
if (shadowMode === 1
|
|
3719
|
-
/* ShadowMode.Synthetic */
|
|
3720
|
-
|| renderMode === 0
|
|
3721
|
-
/* RenderMode.Light */
|
|
3722
|
-
) {
|
|
3581
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
3723
3582
|
elm[shared.KEY__SHADOW_STATIC] = true;
|
|
3724
3583
|
}
|
|
3725
3584
|
}
|
|
3726
|
-
|
|
3727
3585
|
insertNode(elm, parent, anchor, renderer);
|
|
3728
3586
|
}
|
|
3729
|
-
|
|
3730
3587
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3731
3588
|
const {
|
|
3732
3589
|
sel,
|
|
@@ -3741,55 +3598,44 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3741
3598
|
* mechanism that only passes that argument if the constructor is known to be
|
|
3742
3599
|
* an upgradable custom element.
|
|
3743
3600
|
*/
|
|
3744
|
-
|
|
3745
3601
|
let vm;
|
|
3746
|
-
|
|
3747
3602
|
const upgradeCallback = elm => {
|
|
3748
3603
|
// the custom element from the registry is expecting an upgrade callback
|
|
3749
3604
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3750
3605
|
};
|
|
3751
|
-
|
|
3752
3606
|
const connectedCallback = elm => {
|
|
3753
3607
|
if (features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3754
3608
|
connectRootElement(elm);
|
|
3755
3609
|
}
|
|
3756
3610
|
};
|
|
3757
|
-
|
|
3758
3611
|
const disconnectedCallback = elm => {
|
|
3759
3612
|
if (features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3760
3613
|
disconnectRootElement(elm);
|
|
3761
3614
|
}
|
|
3762
|
-
};
|
|
3615
|
+
};
|
|
3616
|
+
// Should never get a tag with upper case letter at this point; the compiler
|
|
3763
3617
|
// should produce only tags with lowercase letters. However, the Java
|
|
3764
3618
|
// compiler may generate tagnames with uppercase letters so - for backwards
|
|
3765
3619
|
// compatibility, we lower case the tagname here.
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
3620
|
const normalizedTagname = sel.toLowerCase();
|
|
3769
3621
|
const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3770
3622
|
vnode.elm = elm;
|
|
3771
3623
|
vnode.vm = vm;
|
|
3772
3624
|
linkNodeToShadow(elm, owner, renderer);
|
|
3773
3625
|
applyStyleScoping(elm, owner, renderer);
|
|
3774
|
-
|
|
3775
3626
|
if (vm) {
|
|
3776
3627
|
allocateChildren(vnode, vm);
|
|
3777
3628
|
}
|
|
3778
|
-
|
|
3779
3629
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3780
3630
|
insertNode(elm, parent, anchor, renderer);
|
|
3781
|
-
|
|
3782
3631
|
if (vm) {
|
|
3783
3632
|
if (process.env.IS_BROWSER) {
|
|
3784
3633
|
if (!features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3785
3634
|
if (process.env.NODE_ENV !== 'production') {
|
|
3786
3635
|
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
|
|
3787
3636
|
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
|
|
3788
|
-
shared.assert.isTrue(vm.state === 0
|
|
3789
|
-
/* VMState.created */
|
|
3790
|
-
, `${vm} cannot be recycled.`);
|
|
3637
|
+
shared.assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
|
|
3791
3638
|
}
|
|
3792
|
-
|
|
3793
3639
|
runConnectedCallback(vm);
|
|
3794
3640
|
}
|
|
3795
3641
|
} else {
|
|
@@ -3798,14 +3644,11 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3798
3644
|
runConnectedCallback(vm);
|
|
3799
3645
|
}
|
|
3800
3646
|
}
|
|
3801
|
-
|
|
3802
3647
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
3803
|
-
|
|
3804
3648
|
if (vm) {
|
|
3805
3649
|
appendVM(vm);
|
|
3806
3650
|
}
|
|
3807
3651
|
}
|
|
3808
|
-
|
|
3809
3652
|
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3810
3653
|
if (n1.ctor !== n2.ctor) {
|
|
3811
3654
|
// If the constructor, unmount the current component and mount a new one using the new
|
|
@@ -3818,17 +3661,14 @@ function patchCustomElement(n1, n2, parent, renderer) {
|
|
|
3818
3661
|
const elm = n2.elm = n1.elm;
|
|
3819
3662
|
const vm = n2.vm = n1.vm;
|
|
3820
3663
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3821
|
-
|
|
3822
3664
|
if (!shared.isUndefined(vm)) {
|
|
3823
3665
|
// in fallback mode, the allocation will always set children to
|
|
3824
3666
|
// empty and delegate the real allocation to the slot elements
|
|
3825
3667
|
allocateChildren(n2, vm);
|
|
3826
|
-
}
|
|
3668
|
+
}
|
|
3669
|
+
// in fallback mode, the children will be always empty, so, nothing
|
|
3827
3670
|
// will happen, but in native, it does allocate the light dom
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
3671
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3831
|
-
|
|
3832
3672
|
if (!shared.isUndefined(vm)) {
|
|
3833
3673
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3834
3674
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
@@ -3836,29 +3676,24 @@ function patchCustomElement(n1, n2, parent, renderer) {
|
|
|
3836
3676
|
}
|
|
3837
3677
|
}
|
|
3838
3678
|
}
|
|
3839
|
-
|
|
3840
3679
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3841
3680
|
for (; start < end; ++start) {
|
|
3842
3681
|
const vnode = vnodes[start];
|
|
3843
|
-
|
|
3844
3682
|
if (isVNode(vnode)) {
|
|
3845
3683
|
mount(vnode, parent, renderer, anchor);
|
|
3846
3684
|
}
|
|
3847
3685
|
}
|
|
3848
3686
|
}
|
|
3849
|
-
|
|
3850
3687
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3851
3688
|
const {
|
|
3852
3689
|
type,
|
|
3853
3690
|
elm,
|
|
3854
3691
|
sel
|
|
3855
|
-
} = vnode;
|
|
3692
|
+
} = vnode;
|
|
3693
|
+
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3856
3694
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3857
|
-
|
|
3858
3695
|
if (doRemove) {
|
|
3859
|
-
if (type === 5
|
|
3860
|
-
/* VNodeType.Fragment */
|
|
3861
|
-
) {
|
|
3696
|
+
if (type === 5 /* VNodeType.Fragment */) {
|
|
3862
3697
|
unmountVNodes(vnode.children, parent, renderer, doRemove);
|
|
3863
3698
|
} else {
|
|
3864
3699
|
// The vnode might or might not have a data.renderer associated to it
|
|
@@ -3866,51 +3701,39 @@ function unmount(vnode, parent, renderer, doRemove = false) {
|
|
|
3866
3701
|
removeNode(elm, parent, renderer);
|
|
3867
3702
|
}
|
|
3868
3703
|
}
|
|
3869
|
-
|
|
3870
3704
|
switch (type) {
|
|
3871
|
-
case 2
|
|
3872
|
-
/* VNodeType.Element */
|
|
3873
|
-
:
|
|
3705
|
+
case 2 /* VNodeType.Element */:
|
|
3874
3706
|
{
|
|
3875
3707
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3876
3708
|
// Only required for synthetic shadow.
|
|
3877
|
-
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
3878
|
-
/* ShadowMode.Synthetic */
|
|
3879
|
-
;
|
|
3709
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3880
3710
|
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3881
3711
|
break;
|
|
3882
3712
|
}
|
|
3883
|
-
|
|
3884
|
-
case 3
|
|
3885
|
-
/* VNodeType.CustomElement */
|
|
3886
|
-
:
|
|
3713
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3887
3714
|
{
|
|
3888
3715
|
const {
|
|
3889
3716
|
vm
|
|
3890
|
-
} = vnode;
|
|
3717
|
+
} = vnode;
|
|
3718
|
+
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
3891
3719
|
// children.
|
|
3892
|
-
|
|
3893
3720
|
if (!shared.isUndefined(vm)) {
|
|
3894
3721
|
removeVM(vm);
|
|
3895
3722
|
}
|
|
3896
3723
|
}
|
|
3897
3724
|
}
|
|
3898
3725
|
}
|
|
3899
|
-
|
|
3900
3726
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3901
3727
|
for (; start < end; ++start) {
|
|
3902
3728
|
const ch = vnodes[start];
|
|
3903
|
-
|
|
3904
3729
|
if (isVNode(ch)) {
|
|
3905
3730
|
unmount(ch, parent, renderer, doRemove);
|
|
3906
3731
|
}
|
|
3907
3732
|
}
|
|
3908
3733
|
}
|
|
3909
|
-
|
|
3910
3734
|
function isVNode(vnode) {
|
|
3911
3735
|
return vnode != null;
|
|
3912
3736
|
}
|
|
3913
|
-
|
|
3914
3737
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
3915
3738
|
const {
|
|
3916
3739
|
renderRoot,
|
|
@@ -3919,19 +3742,14 @@ function linkNodeToShadow(elm, owner, renderer) {
|
|
|
3919
3742
|
} = owner;
|
|
3920
3743
|
const {
|
|
3921
3744
|
isSyntheticShadowDefined
|
|
3922
|
-
} = renderer;
|
|
3923
|
-
|
|
3745
|
+
} = renderer;
|
|
3746
|
+
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3924
3747
|
if (isSyntheticShadowDefined) {
|
|
3925
|
-
if (shadowMode === 1
|
|
3926
|
-
/* ShadowMode.Synthetic */
|
|
3927
|
-
|| renderMode === 0
|
|
3928
|
-
/* RenderMode.Light */
|
|
3929
|
-
) {
|
|
3748
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
3930
3749
|
elm[shared.KEY__SHADOW_RESOLVER] = renderRoot[shared.KEY__SHADOW_RESOLVER];
|
|
3931
3750
|
}
|
|
3932
3751
|
}
|
|
3933
3752
|
}
|
|
3934
|
-
|
|
3935
3753
|
function updateTextContent(vnode, renderer) {
|
|
3936
3754
|
const {
|
|
3937
3755
|
elm,
|
|
@@ -3940,120 +3758,87 @@ function updateTextContent(vnode, renderer) {
|
|
|
3940
3758
|
const {
|
|
3941
3759
|
setText
|
|
3942
3760
|
} = renderer;
|
|
3943
|
-
|
|
3944
3761
|
if (process.env.NODE_ENV !== 'production') {
|
|
3945
3762
|
unlockDomMutation();
|
|
3946
3763
|
}
|
|
3947
|
-
|
|
3948
3764
|
setText(elm, text);
|
|
3949
|
-
|
|
3950
3765
|
if (process.env.NODE_ENV !== 'production') {
|
|
3951
3766
|
lockDomMutation();
|
|
3952
3767
|
}
|
|
3953
3768
|
}
|
|
3954
|
-
|
|
3955
3769
|
function insertNode(node, parent, anchor, renderer) {
|
|
3956
3770
|
if (process.env.NODE_ENV !== 'production') {
|
|
3957
3771
|
unlockDomMutation();
|
|
3958
3772
|
}
|
|
3959
|
-
|
|
3960
3773
|
renderer.insert(node, parent, anchor);
|
|
3961
|
-
|
|
3962
3774
|
if (process.env.NODE_ENV !== 'production') {
|
|
3963
3775
|
lockDomMutation();
|
|
3964
3776
|
}
|
|
3965
3777
|
}
|
|
3966
|
-
|
|
3967
3778
|
function removeNode(node, parent, renderer) {
|
|
3968
3779
|
if (process.env.NODE_ENV !== 'production') {
|
|
3969
3780
|
unlockDomMutation();
|
|
3970
3781
|
}
|
|
3971
|
-
|
|
3972
3782
|
renderer.remove(node, parent);
|
|
3973
|
-
|
|
3974
3783
|
if (process.env.NODE_ENV !== 'production') {
|
|
3975
3784
|
lockDomMutation();
|
|
3976
3785
|
}
|
|
3977
3786
|
}
|
|
3978
|
-
|
|
3979
3787
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3980
3788
|
if (shared.isNull(oldVnode)) {
|
|
3981
3789
|
applyEventListeners(vnode, renderer);
|
|
3982
3790
|
applyStaticClassAttribute(vnode, renderer);
|
|
3983
3791
|
applyStaticStyleAttribute(vnode, renderer);
|
|
3984
|
-
}
|
|
3792
|
+
}
|
|
3793
|
+
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3985
3794
|
// value is set before type=radio.
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
3795
|
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3989
3796
|
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3990
3797
|
patchAttributes(oldVnode, vnode, renderer);
|
|
3991
3798
|
patchProps(oldVnode, vnode, renderer);
|
|
3992
3799
|
}
|
|
3993
|
-
|
|
3994
3800
|
function applyStyleScoping(elm, owner, renderer) {
|
|
3995
3801
|
// Set the class name for `*.scoped.css` style scoping.
|
|
3996
3802
|
const scopeToken = getScopeTokenClass(owner);
|
|
3997
|
-
|
|
3998
3803
|
if (!shared.isNull(scopeToken)) {
|
|
3999
3804
|
const {
|
|
4000
3805
|
getClassList
|
|
4001
|
-
} = renderer;
|
|
3806
|
+
} = renderer;
|
|
3807
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
4002
3808
|
// probably we should have a renderer api for just the add operation
|
|
4003
|
-
|
|
4004
3809
|
getClassList(elm).add(scopeToken);
|
|
4005
|
-
}
|
|
4006
|
-
|
|
4007
|
-
|
|
3810
|
+
}
|
|
3811
|
+
// Set property element for synthetic shadow DOM style scoping.
|
|
4008
3812
|
const {
|
|
4009
3813
|
stylesheetToken: syntheticToken
|
|
4010
3814
|
} = owner.context;
|
|
4011
|
-
|
|
4012
|
-
if (owner.shadowMode === 1
|
|
4013
|
-
/* ShadowMode.Synthetic */
|
|
4014
|
-
&& !shared.isUndefined(syntheticToken)) {
|
|
3815
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !shared.isUndefined(syntheticToken)) {
|
|
4015
3816
|
elm.$shadowToken$ = syntheticToken;
|
|
4016
3817
|
}
|
|
4017
3818
|
}
|
|
4018
|
-
|
|
4019
3819
|
function applyDomManual(elm, vnode) {
|
|
4020
3820
|
var _a;
|
|
4021
|
-
|
|
4022
3821
|
const {
|
|
4023
3822
|
owner,
|
|
4024
3823
|
data: {
|
|
4025
3824
|
context
|
|
4026
3825
|
}
|
|
4027
3826
|
} = vnode;
|
|
4028
|
-
|
|
4029
|
-
if (owner.shadowMode === 1
|
|
4030
|
-
/* ShadowMode.Synthetic */
|
|
4031
|
-
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
4032
|
-
/* LwcDomMode.Manual */
|
|
4033
|
-
) {
|
|
3827
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
|
|
4034
3828
|
elm.$domManual$ = true;
|
|
4035
3829
|
}
|
|
4036
3830
|
}
|
|
4037
|
-
|
|
4038
3831
|
function applyElementRestrictions(elm, vnode) {
|
|
4039
3832
|
var _a, _b;
|
|
4040
|
-
|
|
4041
3833
|
if (process.env.NODE_ENV !== 'production') {
|
|
4042
|
-
const isPortal = vnode.type === 2
|
|
4043
|
-
/*
|
|
4044
|
-
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
4045
|
-
/* LwcDomMode.Manual */
|
|
4046
|
-
;
|
|
4047
|
-
const isLight = vnode.owner.renderMode === 0
|
|
4048
|
-
/* RenderMode.Light */
|
|
4049
|
-
;
|
|
3834
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
|
|
3835
|
+
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4050
3836
|
patchElementWithRestrictions(elm, {
|
|
4051
3837
|
isPortal,
|
|
4052
3838
|
isLight
|
|
4053
3839
|
});
|
|
4054
3840
|
}
|
|
4055
3841
|
}
|
|
4056
|
-
|
|
4057
3842
|
function allocateChildren(vnode, vm) {
|
|
4058
3843
|
// A component with slots will re-render because:
|
|
4059
3844
|
// 1- There is a change of the internal state.
|
|
@@ -4071,41 +3856,31 @@ function allocateChildren(vnode, vm) {
|
|
|
4071
3856
|
renderMode,
|
|
4072
3857
|
shadowMode
|
|
4073
3858
|
} = vm;
|
|
4074
|
-
|
|
4075
3859
|
if (process.env.NODE_ENV !== 'production') {
|
|
4076
3860
|
// If any of the children being allocated is a scoped slot fragment, make sure the receiving
|
|
4077
3861
|
// component is a light DOM component. This is mainly to validate light dom parent running
|
|
4078
3862
|
// in native shadow mode.
|
|
4079
|
-
if (renderMode !== 0
|
|
4080
|
-
/* RenderMode.Light */
|
|
4081
|
-
&& shared.ArraySome.call(children, child => !shared.isNull(child) && isVScopedSlotFragment(child))) {
|
|
3863
|
+
if (renderMode !== 0 /* RenderMode.Light */ && shared.ArraySome.call(children, child => !shared.isNull(child) && isVScopedSlotFragment(child))) {
|
|
4082
3864
|
logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
|
|
4083
3865
|
}
|
|
4084
3866
|
}
|
|
4085
|
-
|
|
4086
|
-
if (shadowMode === 1
|
|
4087
|
-
/* ShadowMode.Synthetic */
|
|
4088
|
-
|| renderMode === 0
|
|
4089
|
-
/* RenderMode.Light */
|
|
4090
|
-
) {
|
|
3867
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4091
3868
|
// slow path
|
|
4092
|
-
allocateInSlot(vm, children, vnode.owner);
|
|
4093
|
-
|
|
4094
|
-
vnode.aChildren = children;
|
|
4095
|
-
|
|
3869
|
+
allocateInSlot(vm, children, vnode.owner);
|
|
3870
|
+
// save the allocated children in case this vnode is reused.
|
|
3871
|
+
vnode.aChildren = children;
|
|
3872
|
+
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4096
3873
|
vnode.children = EmptyArray;
|
|
4097
3874
|
}
|
|
4098
3875
|
}
|
|
4099
|
-
|
|
4100
3876
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4101
|
-
let vm = getAssociatedVMIfPresent(elm);
|
|
3877
|
+
let vm = getAssociatedVMIfPresent(elm);
|
|
3878
|
+
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4102
3879
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4103
3880
|
// called right after invoking `document.createElement`.
|
|
4104
|
-
|
|
4105
3881
|
if (!shared.isUndefined(vm)) {
|
|
4106
3882
|
return vm;
|
|
4107
3883
|
}
|
|
4108
|
-
|
|
4109
3884
|
const {
|
|
4110
3885
|
sel,
|
|
4111
3886
|
mode,
|
|
@@ -4117,48 +3892,37 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4117
3892
|
owner,
|
|
4118
3893
|
tagName: sel
|
|
4119
3894
|
});
|
|
4120
|
-
|
|
4121
3895
|
if (process.env.NODE_ENV !== 'production') {
|
|
4122
3896
|
shared.assert.isTrue(shared.isArray(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4123
3897
|
}
|
|
4124
|
-
|
|
4125
3898
|
return vm;
|
|
4126
3899
|
}
|
|
4127
3900
|
/**
|
|
4128
3901
|
* Collects all slots into a SlotSet, traversing through VFragment Nodes
|
|
4129
3902
|
*/
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
3903
|
function collectSlots(vm, children, cmpSlotsMapping) {
|
|
4133
3904
|
var _a, _b;
|
|
4134
|
-
|
|
4135
3905
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4136
3906
|
const vnode = children[i];
|
|
4137
|
-
|
|
4138
3907
|
if (shared.isNull(vnode)) {
|
|
4139
3908
|
continue;
|
|
4140
|
-
}
|
|
4141
|
-
|
|
4142
|
-
|
|
3909
|
+
}
|
|
3910
|
+
// Dive further iff the content is wrapped in a VFragment
|
|
4143
3911
|
if (isVFragment(vnode)) {
|
|
4144
3912
|
// Remove the text delimiter nodes to avoid overriding default slot content
|
|
4145
3913
|
collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
|
|
4146
3914
|
continue;
|
|
4147
3915
|
}
|
|
4148
|
-
|
|
4149
3916
|
let slotName = '';
|
|
4150
|
-
|
|
4151
3917
|
if (isVBaseElement(vnode)) {
|
|
4152
3918
|
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4153
3919
|
} else if (isVScopedSlotFragment(vnode)) {
|
|
4154
3920
|
slotName = vnode.slotName;
|
|
4155
3921
|
}
|
|
4156
|
-
|
|
4157
3922
|
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4158
3923
|
shared.ArrayPush.call(vnodes, vnode);
|
|
4159
3924
|
}
|
|
4160
3925
|
}
|
|
4161
|
-
|
|
4162
3926
|
function allocateInSlot(vm, children, owner) {
|
|
4163
3927
|
const {
|
|
4164
3928
|
cmpSlots: {
|
|
@@ -4171,28 +3935,22 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4171
3935
|
owner,
|
|
4172
3936
|
slotAssignments: cmpSlotsMapping
|
|
4173
3937
|
};
|
|
4174
|
-
|
|
4175
3938
|
if (shared.isFalse(vm.isDirty)) {
|
|
4176
3939
|
// We need to determine if the old allocation is really different from the new one
|
|
4177
3940
|
// and mark the vm as dirty
|
|
4178
3941
|
const oldKeys = shared.keys(oldSlotsMapping);
|
|
4179
|
-
|
|
4180
3942
|
if (oldKeys.length !== shared.keys(cmpSlotsMapping).length) {
|
|
4181
3943
|
markComponentAsDirty(vm);
|
|
4182
3944
|
return;
|
|
4183
3945
|
}
|
|
4184
|
-
|
|
4185
3946
|
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4186
3947
|
const key = oldKeys[i];
|
|
4187
|
-
|
|
4188
3948
|
if (shared.isUndefined(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4189
3949
|
markComponentAsDirty(vm);
|
|
4190
3950
|
return;
|
|
4191
3951
|
}
|
|
4192
|
-
|
|
4193
3952
|
const oldVNodes = oldSlotsMapping[key];
|
|
4194
3953
|
const vnodes = cmpSlotsMapping[key];
|
|
4195
|
-
|
|
4196
3954
|
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4197
3955
|
if (oldVNodes[j] !== vnodes[j]) {
|
|
4198
3956
|
markComponentAsDirty(vm);
|
|
@@ -4201,40 +3959,33 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4201
3959
|
}
|
|
4202
3960
|
}
|
|
4203
3961
|
}
|
|
4204
|
-
}
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
3962
|
+
}
|
|
3963
|
+
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3964
|
+
const FromIteration = new WeakMap();
|
|
3965
|
+
// dynamic children means it was generated by an iteration
|
|
4208
3966
|
// in a template, and will require a more complex diffing algo.
|
|
4209
|
-
|
|
4210
3967
|
function markAsDynamicChildren(children) {
|
|
4211
3968
|
FromIteration.set(children, 1);
|
|
4212
3969
|
}
|
|
4213
|
-
|
|
4214
3970
|
function hasDynamicChildren(children) {
|
|
4215
3971
|
return FromIteration.has(children);
|
|
4216
3972
|
}
|
|
4217
|
-
|
|
4218
3973
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4219
|
-
const map = {};
|
|
4220
|
-
|
|
3974
|
+
const map = {};
|
|
3975
|
+
// TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4221
3976
|
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4222
3977
|
const ch = children[j];
|
|
4223
|
-
|
|
4224
3978
|
if (isVNode(ch)) {
|
|
4225
3979
|
const {
|
|
4226
3980
|
key
|
|
4227
3981
|
} = ch;
|
|
4228
|
-
|
|
4229
3982
|
if (key !== undefined) {
|
|
4230
3983
|
map[key] = j;
|
|
4231
3984
|
}
|
|
4232
3985
|
}
|
|
4233
3986
|
}
|
|
4234
|
-
|
|
4235
3987
|
return map;
|
|
4236
3988
|
}
|
|
4237
|
-
|
|
4238
3989
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4239
3990
|
let oldStartIdx = 0;
|
|
4240
3991
|
let newStartIdx = 0;
|
|
@@ -4250,7 +4001,6 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
4250
4001
|
let elmToMove;
|
|
4251
4002
|
let before;
|
|
4252
4003
|
let clonedOldCh = false;
|
|
4253
|
-
|
|
4254
4004
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4255
4005
|
if (!isVNode(oldStartVnode)) {
|
|
4256
4006
|
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
@@ -4284,54 +4034,46 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
4284
4034
|
if (oldKeyToIdx === undefined) {
|
|
4285
4035
|
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4286
4036
|
}
|
|
4287
|
-
|
|
4288
4037
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4289
|
-
|
|
4290
4038
|
if (shared.isUndefined(idxInOld)) {
|
|
4291
4039
|
// New element
|
|
4292
4040
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4293
4041
|
newStartVnode = newCh[++newStartIdx];
|
|
4294
4042
|
} else {
|
|
4295
4043
|
elmToMove = oldCh[idxInOld];
|
|
4296
|
-
|
|
4297
4044
|
if (isVNode(elmToMove)) {
|
|
4298
4045
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4299
4046
|
// New element
|
|
4300
4047
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4301
4048
|
} else {
|
|
4302
|
-
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4049
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4050
|
+
// Delete the old child, but copy the array since it is read-only.
|
|
4303
4051
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4304
4052
|
// so we only care about the `oldCh` object inside this function.
|
|
4305
4053
|
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4306
4054
|
// and only clone once.
|
|
4307
|
-
|
|
4308
4055
|
if (!clonedOldCh) {
|
|
4309
4056
|
clonedOldCh = true;
|
|
4310
4057
|
oldCh = [...oldCh];
|
|
4311
|
-
}
|
|
4312
|
-
|
|
4313
|
-
|
|
4058
|
+
}
|
|
4059
|
+
// We've already cloned at least once, so it's no longer read-only
|
|
4314
4060
|
oldCh[idxInOld] = undefined;
|
|
4315
4061
|
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4316
4062
|
}
|
|
4317
4063
|
}
|
|
4318
|
-
|
|
4319
4064
|
newStartVnode = newCh[++newStartIdx];
|
|
4320
4065
|
}
|
|
4321
4066
|
}
|
|
4322
4067
|
}
|
|
4323
|
-
|
|
4324
4068
|
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4325
4069
|
if (oldStartIdx > oldEndIdx) {
|
|
4326
4070
|
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4327
4071
|
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4328
4072
|
let i = newEndIdx;
|
|
4329
4073
|
let n;
|
|
4330
|
-
|
|
4331
4074
|
do {
|
|
4332
4075
|
n = newCh[++i];
|
|
4333
4076
|
} while (!isVNode(n) && i < newChEnd);
|
|
4334
|
-
|
|
4335
4077
|
before = isVNode(n) ? n.elm : null;
|
|
4336
4078
|
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4337
4079
|
} else {
|
|
@@ -4339,32 +4081,26 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
4339
4081
|
}
|
|
4340
4082
|
}
|
|
4341
4083
|
}
|
|
4342
|
-
|
|
4343
4084
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4344
4085
|
const c1Length = c1.length;
|
|
4345
4086
|
const c2Length = c2.length;
|
|
4346
|
-
|
|
4347
4087
|
if (c1Length === 0) {
|
|
4348
4088
|
// the old list is empty, we can directly insert anything new
|
|
4349
4089
|
mountVNodes(c2, parent, renderer, null);
|
|
4350
4090
|
return;
|
|
4351
4091
|
}
|
|
4352
|
-
|
|
4353
4092
|
if (c2Length === 0) {
|
|
4354
4093
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4355
4094
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4356
4095
|
unmountVNodes(c1, parent, renderer, true);
|
|
4357
4096
|
return;
|
|
4358
|
-
}
|
|
4097
|
+
}
|
|
4098
|
+
// if the old list is not empty, the new list MUST have the same
|
|
4359
4099
|
// amount of nodes, that's why we call this static children
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
4100
|
let anchor = null;
|
|
4363
|
-
|
|
4364
4101
|
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4365
4102
|
const n1 = c1[i];
|
|
4366
4103
|
const n2 = c2[i];
|
|
4367
|
-
|
|
4368
4104
|
if (n2 !== n1) {
|
|
4369
4105
|
if (isVNode(n1)) {
|
|
4370
4106
|
if (isVNode(n2)) {
|
|
@@ -5354,42 +5090,30 @@ function invokeServiceHook(vm, cbs) {
|
|
|
5354
5090
|
*/
|
|
5355
5091
|
let idx = 0;
|
|
5356
5092
|
/** The internal slot used to associate different objects the engine manipulates with the VM */
|
|
5357
|
-
|
|
5358
5093
|
const ViewModelReflection = new WeakMap();
|
|
5359
|
-
|
|
5360
5094
|
function callHook(cmp, fn, args = []) {
|
|
5361
5095
|
return fn.apply(cmp, args);
|
|
5362
5096
|
}
|
|
5363
|
-
|
|
5364
5097
|
function setHook(cmp, prop, newValue) {
|
|
5365
5098
|
cmp[prop] = newValue;
|
|
5366
5099
|
}
|
|
5367
|
-
|
|
5368
5100
|
function getHook(cmp, prop) {
|
|
5369
5101
|
return cmp[prop];
|
|
5370
5102
|
}
|
|
5371
|
-
|
|
5372
5103
|
function rerenderVM(vm) {
|
|
5373
5104
|
rehydrate(vm);
|
|
5374
5105
|
}
|
|
5375
5106
|
function connectRootElement(elm) {
|
|
5376
5107
|
const vm = getAssociatedVM(elm);
|
|
5377
|
-
logGlobalOperationStart(7
|
|
5378
|
-
|
|
5379
|
-
, vm); // Usually means moving the element from one place to another, which is observable via
|
|
5108
|
+
logGlobalOperationStart(7 /* OperationId.GlobalHydrate */, vm);
|
|
5109
|
+
// Usually means moving the element from one place to another, which is observable via
|
|
5380
5110
|
// life-cycle hooks.
|
|
5381
|
-
|
|
5382
|
-
if (vm.state === 1
|
|
5383
|
-
/* VMState.connected */
|
|
5384
|
-
) {
|
|
5111
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
5385
5112
|
disconnectRootElement(elm);
|
|
5386
5113
|
}
|
|
5387
|
-
|
|
5388
5114
|
runConnectedCallback(vm);
|
|
5389
5115
|
rehydrate(vm);
|
|
5390
|
-
logGlobalOperationEnd(7
|
|
5391
|
-
/* OperationId.GlobalHydrate */
|
|
5392
|
-
, vm);
|
|
5116
|
+
logGlobalOperationEnd(7 /* OperationId.GlobalHydrate */, vm);
|
|
5393
5117
|
}
|
|
5394
5118
|
function disconnectRootElement(elm) {
|
|
5395
5119
|
const vm = getAssociatedVM(elm);
|
|
@@ -5397,65 +5121,48 @@ function disconnectRootElement(elm) {
|
|
|
5397
5121
|
}
|
|
5398
5122
|
function appendVM(vm) {
|
|
5399
5123
|
rehydrate(vm);
|
|
5400
|
-
}
|
|
5124
|
+
}
|
|
5125
|
+
// just in case the component comes back, with this we guarantee re-rendering it
|
|
5401
5126
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5402
|
-
|
|
5403
5127
|
function resetComponentStateWhenRemoved(vm) {
|
|
5404
5128
|
const {
|
|
5405
5129
|
state
|
|
5406
5130
|
} = vm;
|
|
5407
|
-
|
|
5408
|
-
if (state !== 2
|
|
5409
|
-
/* VMState.disconnected */
|
|
5410
|
-
) {
|
|
5131
|
+
if (state !== 2 /* VMState.disconnected */) {
|
|
5411
5132
|
const {
|
|
5412
5133
|
oar,
|
|
5413
5134
|
tro
|
|
5414
|
-
} = vm;
|
|
5415
|
-
|
|
5416
|
-
tro.reset();
|
|
5417
|
-
|
|
5135
|
+
} = vm;
|
|
5136
|
+
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5137
|
+
tro.reset();
|
|
5138
|
+
// Making sure that any observing accessor record will not trigger the setter to be reinvoked
|
|
5418
5139
|
for (const key in oar) {
|
|
5419
5140
|
oar[key].reset();
|
|
5420
5141
|
}
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5142
|
+
runDisconnectedCallback(vm);
|
|
5143
|
+
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5424
5144
|
runChildNodesDisconnectedCallback(vm);
|
|
5425
5145
|
runLightChildNodesDisconnectedCallback(vm);
|
|
5426
5146
|
}
|
|
5427
|
-
|
|
5428
5147
|
if (process.env.NODE_ENV !== 'production') {
|
|
5429
5148
|
removeActiveVM(vm);
|
|
5430
5149
|
}
|
|
5431
|
-
}
|
|
5150
|
+
}
|
|
5151
|
+
// this method is triggered by the diffing algo only when a vnode from the
|
|
5432
5152
|
// old vnode.children is removed from the DOM.
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
5153
|
function removeVM(vm) {
|
|
5436
5154
|
if (process.env.NODE_ENV !== 'production') {
|
|
5437
|
-
shared.assert.isTrue(vm.state === 1
|
|
5438
|
-
/* VMState.connected */
|
|
5439
|
-
|| vm.state === 2
|
|
5440
|
-
/* VMState.disconnected */
|
|
5441
|
-
, `${vm} must have been connected.`);
|
|
5155
|
+
shared.assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
|
|
5442
5156
|
}
|
|
5443
|
-
|
|
5444
5157
|
resetComponentStateWhenRemoved(vm);
|
|
5445
5158
|
}
|
|
5446
|
-
|
|
5447
5159
|
function getNearestShadowAncestor(vm) {
|
|
5448
5160
|
let ancestor = vm.owner;
|
|
5449
|
-
|
|
5450
|
-
while (!shared.isNull(ancestor) && ancestor.renderMode === 0
|
|
5451
|
-
/* RenderMode.Light */
|
|
5452
|
-
) {
|
|
5161
|
+
while (!shared.isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5453
5162
|
ancestor = ancestor.owner;
|
|
5454
5163
|
}
|
|
5455
|
-
|
|
5456
5164
|
return ancestor;
|
|
5457
5165
|
}
|
|
5458
|
-
|
|
5459
5166
|
function createVM(elm, ctor, renderer, options) {
|
|
5460
5167
|
const {
|
|
5461
5168
|
mode,
|
|
@@ -5468,9 +5175,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5468
5175
|
elm,
|
|
5469
5176
|
def,
|
|
5470
5177
|
idx: idx++,
|
|
5471
|
-
state: 0
|
|
5472
|
-
/* VMState.created */
|
|
5473
|
-
,
|
|
5178
|
+
state: 0 /* VMState.created */,
|
|
5474
5179
|
isScheduled: false,
|
|
5475
5180
|
isDirty: true,
|
|
5476
5181
|
tagName,
|
|
@@ -5512,31 +5217,27 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5512
5217
|
getHook,
|
|
5513
5218
|
renderer
|
|
5514
5219
|
};
|
|
5220
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5221
|
+
vm.debugInfo = shared.create(null);
|
|
5222
|
+
}
|
|
5515
5223
|
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5516
5224
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5517
|
-
|
|
5518
5225
|
if (process.env.NODE_ENV !== 'production') {
|
|
5519
5226
|
vm.toString = () => {
|
|
5520
5227
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5521
5228
|
};
|
|
5522
|
-
|
|
5523
5229
|
if (features.lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5524
|
-
vm.shadowMode = 0
|
|
5525
|
-
/* ShadowMode.Native */
|
|
5526
|
-
;
|
|
5230
|
+
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5527
5231
|
}
|
|
5528
|
-
}
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5232
|
+
}
|
|
5233
|
+
// Create component instance associated to the vm and the element.
|
|
5234
|
+
invokeComponentConstructor(vm, def.ctor);
|
|
5235
|
+
// Initializing the wire decorator per instance only when really needed
|
|
5533
5236
|
if (hasWireAdapters(vm)) {
|
|
5534
5237
|
installWireAdapters(vm);
|
|
5535
5238
|
}
|
|
5536
|
-
|
|
5537
5239
|
return vm;
|
|
5538
5240
|
}
|
|
5539
|
-
|
|
5540
5241
|
function computeShadowMode(vm, renderer) {
|
|
5541
5242
|
const {
|
|
5542
5243
|
def
|
|
@@ -5546,136 +5247,98 @@ function computeShadowMode(vm, renderer) {
|
|
|
5546
5247
|
isNativeShadowDefined
|
|
5547
5248
|
} = renderer;
|
|
5548
5249
|
let shadowMode;
|
|
5549
|
-
|
|
5550
5250
|
if (isSyntheticShadowDefined) {
|
|
5551
|
-
if (def.renderMode === 0
|
|
5552
|
-
/* RenderMode.Light */
|
|
5553
|
-
) {
|
|
5251
|
+
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
5554
5252
|
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
5555
5253
|
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
5556
|
-
shadowMode = 0
|
|
5557
|
-
/* ShadowMode.Native */
|
|
5558
|
-
;
|
|
5254
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5559
5255
|
} else if (isNativeShadowDefined) {
|
|
5560
5256
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5561
5257
|
// the if-condition.
|
|
5562
5258
|
if (features.lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5563
|
-
if (def.shadowSupportMode === "any"
|
|
5564
|
-
|
|
5565
|
-
) {
|
|
5566
|
-
shadowMode = 0
|
|
5567
|
-
/* ShadowMode.Native */
|
|
5568
|
-
;
|
|
5259
|
+
if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
5260
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5569
5261
|
} else {
|
|
5570
5262
|
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
5571
|
-
|
|
5572
|
-
if (!shared.isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
|
|
5573
|
-
/* ShadowMode.Native */
|
|
5574
|
-
) {
|
|
5263
|
+
if (!shared.isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5575
5264
|
// Transitive support for native Shadow DOM. A component in native mode
|
|
5576
5265
|
// transitively opts all of its descendants into native.
|
|
5577
|
-
shadowMode = 0
|
|
5578
|
-
/* ShadowMode.Native */
|
|
5579
|
-
;
|
|
5266
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5580
5267
|
} else {
|
|
5581
5268
|
// Synthetic if neither this component nor any of its ancestors are configured
|
|
5582
5269
|
// to be native.
|
|
5583
|
-
shadowMode = 1
|
|
5584
|
-
/* ShadowMode.Synthetic */
|
|
5585
|
-
;
|
|
5270
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5586
5271
|
}
|
|
5587
5272
|
}
|
|
5588
5273
|
} else {
|
|
5589
|
-
shadowMode = 1
|
|
5590
|
-
/* ShadowMode.Synthetic */
|
|
5591
|
-
;
|
|
5274
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5592
5275
|
}
|
|
5593
5276
|
} else {
|
|
5594
5277
|
// Synthetic if there is no native Shadow DOM support.
|
|
5595
|
-
shadowMode = 1
|
|
5596
|
-
/* ShadowMode.Synthetic */
|
|
5597
|
-
;
|
|
5278
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5598
5279
|
}
|
|
5599
5280
|
} else {
|
|
5600
5281
|
// Native if the synthetic shadow polyfill is unavailable.
|
|
5601
|
-
shadowMode = 0
|
|
5602
|
-
/* ShadowMode.Native */
|
|
5603
|
-
;
|
|
5282
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5604
5283
|
}
|
|
5605
5284
|
|
|
5606
5285
|
return shadowMode;
|
|
5607
5286
|
}
|
|
5608
|
-
|
|
5609
5287
|
function assertIsVM(obj) {
|
|
5610
5288
|
if (shared.isNull(obj) || !shared.isObject(obj) || !('renderRoot' in obj)) {
|
|
5611
5289
|
throw new TypeError(`${obj} is not a VM.`);
|
|
5612
5290
|
}
|
|
5613
5291
|
}
|
|
5614
|
-
|
|
5615
5292
|
function associateVM(obj, vm) {
|
|
5616
5293
|
ViewModelReflection.set(obj, vm);
|
|
5617
5294
|
}
|
|
5618
5295
|
function getAssociatedVM(obj) {
|
|
5619
5296
|
const vm = ViewModelReflection.get(obj);
|
|
5620
|
-
|
|
5621
5297
|
if (process.env.NODE_ENV !== 'production') {
|
|
5622
5298
|
assertIsVM(vm);
|
|
5623
5299
|
}
|
|
5624
|
-
|
|
5625
5300
|
return vm;
|
|
5626
5301
|
}
|
|
5627
5302
|
function getAssociatedVMIfPresent(obj) {
|
|
5628
5303
|
const maybeVm = ViewModelReflection.get(obj);
|
|
5629
|
-
|
|
5630
5304
|
if (process.env.NODE_ENV !== 'production') {
|
|
5631
5305
|
if (!shared.isUndefined(maybeVm)) {
|
|
5632
5306
|
assertIsVM(maybeVm);
|
|
5633
5307
|
}
|
|
5634
5308
|
}
|
|
5635
|
-
|
|
5636
5309
|
return maybeVm;
|
|
5637
5310
|
}
|
|
5638
|
-
|
|
5639
5311
|
function rehydrate(vm) {
|
|
5640
5312
|
if (shared.isTrue(vm.isDirty)) {
|
|
5641
5313
|
const children = renderComponent(vm);
|
|
5642
5314
|
patchShadowRoot(vm, children);
|
|
5643
5315
|
}
|
|
5644
5316
|
}
|
|
5645
|
-
|
|
5646
5317
|
function patchShadowRoot(vm, newCh) {
|
|
5647
5318
|
const {
|
|
5648
5319
|
renderRoot,
|
|
5649
5320
|
children: oldCh,
|
|
5650
5321
|
renderer
|
|
5651
|
-
} = vm;
|
|
5652
|
-
|
|
5322
|
+
} = vm;
|
|
5323
|
+
// caching the new children collection
|
|
5653
5324
|
vm.children = newCh;
|
|
5654
|
-
|
|
5655
5325
|
if (newCh.length > 0 || oldCh.length > 0) {
|
|
5656
5326
|
// patch function mutates vnodes by adding the element reference,
|
|
5657
5327
|
// however, if patching fails it contains partial changes.
|
|
5658
5328
|
if (oldCh !== newCh) {
|
|
5659
5329
|
runWithBoundaryProtection(vm, vm, () => {
|
|
5660
5330
|
// pre
|
|
5661
|
-
logOperationStart(2
|
|
5662
|
-
/* OperationId.Patch */
|
|
5663
|
-
, vm);
|
|
5331
|
+
logOperationStart(2 /* OperationId.Patch */, vm);
|
|
5664
5332
|
}, () => {
|
|
5665
5333
|
// job
|
|
5666
5334
|
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5667
5335
|
}, () => {
|
|
5668
5336
|
// post
|
|
5669
|
-
logOperationEnd(2
|
|
5670
|
-
/* OperationId.Patch */
|
|
5671
|
-
, vm);
|
|
5337
|
+
logOperationEnd(2 /* OperationId.Patch */, vm);
|
|
5672
5338
|
});
|
|
5673
5339
|
}
|
|
5674
5340
|
}
|
|
5675
|
-
|
|
5676
|
-
if (vm.state === 1
|
|
5677
|
-
/* VMState.connected */
|
|
5678
|
-
) {
|
|
5341
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
5679
5342
|
// If the element is connected, that means connectedCallback was already issued, and
|
|
5680
5343
|
// any successive rendering should finish with the call to renderedCallback, otherwise
|
|
5681
5344
|
// the connectedCallback will take care of calling it in the right order at the end of
|
|
@@ -5683,53 +5346,37 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5683
5346
|
runRenderedCallback(vm);
|
|
5684
5347
|
}
|
|
5685
5348
|
}
|
|
5686
|
-
|
|
5687
5349
|
function runRenderedCallback(vm) {
|
|
5688
5350
|
const {
|
|
5689
5351
|
def: {
|
|
5690
5352
|
renderedCallback
|
|
5691
5353
|
}
|
|
5692
5354
|
} = vm;
|
|
5693
|
-
|
|
5694
5355
|
if (!process.env.IS_BROWSER) {
|
|
5695
5356
|
return;
|
|
5696
5357
|
}
|
|
5697
|
-
|
|
5698
5358
|
const {
|
|
5699
5359
|
rendered
|
|
5700
5360
|
} = Services;
|
|
5701
|
-
|
|
5702
5361
|
if (rendered) {
|
|
5703
5362
|
invokeServiceHook(vm, rendered);
|
|
5704
5363
|
}
|
|
5705
|
-
|
|
5706
5364
|
if (!shared.isUndefined(renderedCallback)) {
|
|
5707
|
-
logOperationStart(4
|
|
5708
|
-
/* OperationId.RenderedCallback */
|
|
5709
|
-
, vm);
|
|
5365
|
+
logOperationStart(4 /* OperationId.RenderedCallback */, vm);
|
|
5710
5366
|
invokeComponentCallback(vm, renderedCallback);
|
|
5711
|
-
logOperationEnd(4
|
|
5712
|
-
/* OperationId.RenderedCallback */
|
|
5713
|
-
, vm);
|
|
5367
|
+
logOperationEnd(4 /* OperationId.RenderedCallback */, vm);
|
|
5714
5368
|
}
|
|
5715
5369
|
}
|
|
5716
5370
|
let rehydrateQueue = [];
|
|
5717
|
-
|
|
5718
5371
|
function flushRehydrationQueue() {
|
|
5719
|
-
logGlobalOperationStart(8
|
|
5720
|
-
/* OperationId.GlobalRehydrate */
|
|
5721
|
-
);
|
|
5722
|
-
|
|
5372
|
+
logGlobalOperationStart(8 /* OperationId.GlobalRehydrate */);
|
|
5723
5373
|
if (process.env.NODE_ENV !== 'production') {
|
|
5724
5374
|
shared.assert.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
|
|
5725
5375
|
}
|
|
5726
|
-
|
|
5727
5376
|
const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
|
|
5728
5377
|
rehydrateQueue = []; // reset to a new queue
|
|
5729
|
-
|
|
5730
5378
|
for (let i = 0, len = vms.length; i < len; i += 1) {
|
|
5731
5379
|
const vm = vms[i];
|
|
5732
|
-
|
|
5733
5380
|
try {
|
|
5734
5381
|
rehydrate(vm);
|
|
5735
5382
|
} catch (error) {
|
|
@@ -5738,78 +5385,54 @@ function flushRehydrationQueue() {
|
|
|
5738
5385
|
if (rehydrateQueue.length === 0) {
|
|
5739
5386
|
addCallbackToNextTick(flushRehydrationQueue);
|
|
5740
5387
|
}
|
|
5741
|
-
|
|
5742
5388
|
shared.ArrayUnshift.apply(rehydrateQueue, shared.ArraySlice.call(vms, i + 1));
|
|
5743
|
-
}
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
/* OperationId.GlobalRehydrate */
|
|
5748
|
-
); // re-throwing the original error will break the current tick, but since the next tick is
|
|
5389
|
+
}
|
|
5390
|
+
// we need to end the measure before throwing.
|
|
5391
|
+
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
5392
|
+
// re-throwing the original error will break the current tick, but since the next tick is
|
|
5749
5393
|
// already scheduled, it should continue patching the rest.
|
|
5750
|
-
|
|
5751
5394
|
throw error; // eslint-disable-line no-unsafe-finally
|
|
5752
5395
|
}
|
|
5753
5396
|
}
|
|
5754
5397
|
|
|
5755
|
-
logGlobalOperationEnd(8
|
|
5756
|
-
/* OperationId.GlobalRehydrate */
|
|
5757
|
-
);
|
|
5398
|
+
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
5758
5399
|
}
|
|
5759
5400
|
|
|
5760
5401
|
function runConnectedCallback(vm) {
|
|
5761
5402
|
const {
|
|
5762
5403
|
state
|
|
5763
5404
|
} = vm;
|
|
5764
|
-
|
|
5765
|
-
if (state === 1
|
|
5766
|
-
/* VMState.connected */
|
|
5767
|
-
) {
|
|
5405
|
+
if (state === 1 /* VMState.connected */) {
|
|
5768
5406
|
return; // nothing to do since it was already connected
|
|
5769
5407
|
}
|
|
5770
5408
|
|
|
5771
|
-
vm.state = 1
|
|
5772
|
-
|
|
5773
|
-
; // reporting connection
|
|
5774
|
-
|
|
5409
|
+
vm.state = 1 /* VMState.connected */;
|
|
5410
|
+
// reporting connection
|
|
5775
5411
|
const {
|
|
5776
5412
|
connected
|
|
5777
5413
|
} = Services;
|
|
5778
|
-
|
|
5779
5414
|
if (connected) {
|
|
5780
5415
|
invokeServiceHook(vm, connected);
|
|
5781
5416
|
}
|
|
5782
|
-
|
|
5783
5417
|
if (hasWireAdapters(vm)) {
|
|
5784
5418
|
connectWireAdapters(vm);
|
|
5785
5419
|
}
|
|
5786
|
-
|
|
5787
5420
|
const {
|
|
5788
5421
|
connectedCallback
|
|
5789
5422
|
} = vm.def;
|
|
5790
|
-
|
|
5791
5423
|
if (!shared.isUndefined(connectedCallback)) {
|
|
5792
|
-
logOperationStart(3
|
|
5793
|
-
/* OperationId.ConnectedCallback */
|
|
5794
|
-
, vm);
|
|
5424
|
+
logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
|
|
5795
5425
|
invokeComponentCallback(vm, connectedCallback);
|
|
5796
|
-
logOperationEnd(3
|
|
5797
|
-
/* OperationId.ConnectedCallback */
|
|
5798
|
-
, vm);
|
|
5426
|
+
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
5799
5427
|
}
|
|
5800
5428
|
}
|
|
5801
|
-
|
|
5802
5429
|
function hasWireAdapters(vm) {
|
|
5803
5430
|
return shared.getOwnPropertyNames(vm.def.wire).length > 0;
|
|
5804
5431
|
}
|
|
5805
|
-
|
|
5806
5432
|
function runDisconnectedCallback(vm) {
|
|
5807
5433
|
if (process.env.NODE_ENV !== 'production') {
|
|
5808
|
-
shared.assert.isTrue(vm.state !== 2
|
|
5809
|
-
/* VMState.disconnected */
|
|
5810
|
-
, `${vm} must be inserted.`);
|
|
5434
|
+
shared.assert.isTrue(vm.state !== 2 /* VMState.disconnected */, `${vm} must be inserted.`);
|
|
5811
5435
|
}
|
|
5812
|
-
|
|
5813
5436
|
if (shared.isFalse(vm.isDirty)) {
|
|
5814
5437
|
// this guarantees that if the component is reused/reinserted,
|
|
5815
5438
|
// it will be re-rendered because we are disconnecting the reactivity
|
|
@@ -5817,67 +5440,54 @@ function runDisconnectedCallback(vm) {
|
|
|
5817
5440
|
// of disconnected components.
|
|
5818
5441
|
vm.isDirty = true;
|
|
5819
5442
|
}
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
/* VMState.disconnected */
|
|
5823
|
-
; // reporting disconnection
|
|
5824
|
-
|
|
5443
|
+
vm.state = 2 /* VMState.disconnected */;
|
|
5444
|
+
// reporting disconnection
|
|
5825
5445
|
const {
|
|
5826
5446
|
disconnected
|
|
5827
5447
|
} = Services;
|
|
5828
|
-
|
|
5829
5448
|
if (disconnected) {
|
|
5830
5449
|
invokeServiceHook(vm, disconnected);
|
|
5831
5450
|
}
|
|
5832
|
-
|
|
5833
5451
|
if (hasWireAdapters(vm)) {
|
|
5834
5452
|
disconnectWireAdapters(vm);
|
|
5835
5453
|
}
|
|
5836
|
-
|
|
5837
5454
|
const {
|
|
5838
5455
|
disconnectedCallback
|
|
5839
5456
|
} = vm.def;
|
|
5840
|
-
|
|
5841
5457
|
if (!shared.isUndefined(disconnectedCallback)) {
|
|
5842
|
-
logOperationStart(5
|
|
5843
|
-
/* OperationId.DisconnectedCallback */
|
|
5844
|
-
, vm);
|
|
5458
|
+
logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
|
|
5845
5459
|
invokeComponentCallback(vm, disconnectedCallback);
|
|
5846
|
-
logOperationEnd(5
|
|
5847
|
-
/* OperationId.DisconnectedCallback */
|
|
5848
|
-
, vm);
|
|
5460
|
+
logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
|
|
5849
5461
|
}
|
|
5850
5462
|
}
|
|
5851
|
-
|
|
5852
5463
|
function runChildNodesDisconnectedCallback(vm) {
|
|
5853
5464
|
const {
|
|
5854
5465
|
velements: vCustomElementCollection
|
|
5855
|
-
} = vm;
|
|
5466
|
+
} = vm;
|
|
5467
|
+
// Reporting disconnection for every child in inverse order since they are
|
|
5856
5468
|
// inserted in reserved order.
|
|
5857
|
-
|
|
5858
5469
|
for (let i = vCustomElementCollection.length - 1; i >= 0; i -= 1) {
|
|
5859
5470
|
const {
|
|
5860
5471
|
elm
|
|
5861
|
-
} = vCustomElementCollection[i];
|
|
5472
|
+
} = vCustomElementCollection[i];
|
|
5473
|
+
// There are two cases where the element could be undefined:
|
|
5862
5474
|
// * when there is an error during the construction phase, and an error
|
|
5863
5475
|
// boundary picks it, there is a possibility that the VCustomElement
|
|
5864
5476
|
// is not properly initialized, and therefore is should be ignored.
|
|
5865
5477
|
// * when slotted custom element is not used by the element where it is
|
|
5866
5478
|
// slotted into it, as a result, the custom element was never
|
|
5867
5479
|
// initialized.
|
|
5868
|
-
|
|
5869
5480
|
if (!shared.isUndefined(elm)) {
|
|
5870
|
-
const childVM = getAssociatedVMIfPresent(elm);
|
|
5481
|
+
const childVM = getAssociatedVMIfPresent(elm);
|
|
5482
|
+
// The VM associated with the element might be associated undefined
|
|
5871
5483
|
// in the case where the VM failed in the middle of its creation,
|
|
5872
5484
|
// eg: constructor throwing before invoking super().
|
|
5873
|
-
|
|
5874
5485
|
if (!shared.isUndefined(childVM)) {
|
|
5875
5486
|
resetComponentStateWhenRemoved(childVM);
|
|
5876
5487
|
}
|
|
5877
5488
|
}
|
|
5878
5489
|
}
|
|
5879
5490
|
}
|
|
5880
|
-
|
|
5881
5491
|
function runLightChildNodesDisconnectedCallback(vm) {
|
|
5882
5492
|
const {
|
|
5883
5493
|
aChildren: adoptedChildren
|
|
@@ -5891,23 +5501,15 @@ function runLightChildNodesDisconnectedCallback(vm) {
|
|
|
5891
5501
|
* custom element itself will trigger the removal of anything slotted or anything
|
|
5892
5502
|
* defined on its shadow.
|
|
5893
5503
|
*/
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
5504
|
function recursivelyDisconnectChildren(vnodes) {
|
|
5897
5505
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
5898
5506
|
const vnode = vnodes[i];
|
|
5899
|
-
|
|
5900
5507
|
if (!shared.isNull(vnode) && !shared.isUndefined(vnode.elm)) {
|
|
5901
5508
|
switch (vnode.type) {
|
|
5902
|
-
case 2
|
|
5903
|
-
/* VNodeType.Element */
|
|
5904
|
-
:
|
|
5509
|
+
case 2 /* VNodeType.Element */:
|
|
5905
5510
|
recursivelyDisconnectChildren(vnode.children);
|
|
5906
5511
|
break;
|
|
5907
|
-
|
|
5908
|
-
case 3
|
|
5909
|
-
/* VNodeType.CustomElement */
|
|
5910
|
-
:
|
|
5512
|
+
case 3 /* VNodeType.CustomElement */:
|
|
5911
5513
|
{
|
|
5912
5514
|
const vm = getAssociatedVM(vnode.elm);
|
|
5913
5515
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -5916,12 +5518,11 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5916
5518
|
}
|
|
5917
5519
|
}
|
|
5918
5520
|
}
|
|
5919
|
-
}
|
|
5521
|
+
}
|
|
5522
|
+
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
5920
5523
|
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
5921
5524
|
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
5922
5525
|
// children VNodes might not be representing the current state of the DOM.
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
5526
|
function resetComponentRoot(vm) {
|
|
5926
5527
|
const {
|
|
5927
5528
|
children,
|
|
@@ -5930,15 +5531,12 @@ function resetComponentRoot(vm) {
|
|
|
5930
5531
|
remove
|
|
5931
5532
|
}
|
|
5932
5533
|
} = vm;
|
|
5933
|
-
|
|
5934
5534
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5935
5535
|
const child = children[i];
|
|
5936
|
-
|
|
5937
5536
|
if (!shared.isNull(child) && !shared.isUndefined(child.elm)) {
|
|
5938
5537
|
remove(child.elm, renderRoot);
|
|
5939
5538
|
}
|
|
5940
5539
|
}
|
|
5941
|
-
|
|
5942
5540
|
vm.children = EmptyArray;
|
|
5943
5541
|
runChildNodesDisconnectedCallback(vm);
|
|
5944
5542
|
vm.velements = EmptyArray;
|
|
@@ -5947,58 +5545,43 @@ function scheduleRehydration(vm) {
|
|
|
5947
5545
|
if (!process.env.IS_BROWSER || shared.isTrue(vm.isScheduled)) {
|
|
5948
5546
|
return;
|
|
5949
5547
|
}
|
|
5950
|
-
|
|
5951
5548
|
vm.isScheduled = true;
|
|
5952
|
-
|
|
5953
5549
|
if (rehydrateQueue.length === 0) {
|
|
5954
5550
|
addCallbackToNextTick(flushRehydrationQueue);
|
|
5955
5551
|
}
|
|
5956
|
-
|
|
5957
5552
|
shared.ArrayPush.call(rehydrateQueue, vm);
|
|
5958
5553
|
}
|
|
5959
|
-
|
|
5960
5554
|
function getErrorBoundaryVM(vm) {
|
|
5961
5555
|
let currentVm = vm;
|
|
5962
|
-
|
|
5963
5556
|
while (!shared.isNull(currentVm)) {
|
|
5964
5557
|
if (!shared.isUndefined(currentVm.def.errorCallback)) {
|
|
5965
5558
|
return currentVm;
|
|
5966
5559
|
}
|
|
5967
|
-
|
|
5968
5560
|
currentVm = currentVm.owner;
|
|
5969
5561
|
}
|
|
5970
5562
|
}
|
|
5971
|
-
|
|
5972
5563
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
5973
5564
|
let error;
|
|
5974
5565
|
pre();
|
|
5975
|
-
|
|
5976
5566
|
try {
|
|
5977
5567
|
job();
|
|
5978
5568
|
} catch (e) {
|
|
5979
5569
|
error = Object(e);
|
|
5980
5570
|
} finally {
|
|
5981
5571
|
post();
|
|
5982
|
-
|
|
5983
5572
|
if (!shared.isUndefined(error)) {
|
|
5984
5573
|
addErrorComponentStack(vm, error);
|
|
5985
5574
|
const errorBoundaryVm = shared.isNull(owner) ? undefined : getErrorBoundaryVM(owner);
|
|
5986
|
-
|
|
5987
5575
|
if (shared.isUndefined(errorBoundaryVm)) {
|
|
5988
5576
|
throw error; // eslint-disable-line no-unsafe-finally
|
|
5989
5577
|
}
|
|
5990
5578
|
|
|
5991
5579
|
resetComponentRoot(vm); // remove offenders
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
/* OperationId.ErrorCallback */
|
|
5995
|
-
, vm); // error boundaries must have an ErrorCallback
|
|
5996
|
-
|
|
5580
|
+
logOperationStart(6 /* OperationId.ErrorCallback */, vm);
|
|
5581
|
+
// error boundaries must have an ErrorCallback
|
|
5997
5582
|
const errorCallback = errorBoundaryVm.def.errorCallback;
|
|
5998
5583
|
invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
|
5999
|
-
logOperationEnd(6
|
|
6000
|
-
/* OperationId.ErrorCallback */
|
|
6001
|
-
, vm);
|
|
5584
|
+
logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
|
|
6002
5585
|
}
|
|
6003
5586
|
}
|
|
6004
5587
|
}
|
|
@@ -6012,7 +5595,6 @@ function forceRehydration(vm) {
|
|
|
6012
5595
|
// content of the shadowRoot, this way we can guarantee that all children
|
|
6013
5596
|
// elements will be throw away, and new instances will be created.
|
|
6014
5597
|
vm.cmpTemplate = () => [];
|
|
6015
|
-
|
|
6016
5598
|
if (shared.isFalse(vm.isDirty)) {
|
|
6017
5599
|
// forcing the vm to rehydrate in the next tick
|
|
6018
5600
|
markComponentAsDirty(vm);
|
|
@@ -6028,6 +5610,7 @@ function forceRehydration(vm) {
|
|
|
6028
5610
|
*/
|
|
6029
5611
|
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
6030
5612
|
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
5613
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
6031
5614
|
const WireMetaMap = new Map();
|
|
6032
5615
|
class WireContextRegistrationEvent extends CustomEvent {
|
|
6033
5616
|
constructor(adapterToken, {
|
|
@@ -6047,15 +5630,12 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
6047
5630
|
}
|
|
6048
5631
|
});
|
|
6049
5632
|
}
|
|
6050
|
-
|
|
6051
5633
|
}
|
|
6052
|
-
|
|
6053
5634
|
function createFieldDataCallback(vm, name) {
|
|
6054
5635
|
return value => {
|
|
6055
5636
|
updateComponentValue(vm, name, value);
|
|
6056
5637
|
};
|
|
6057
5638
|
}
|
|
6058
|
-
|
|
6059
5639
|
function createMethodDataCallback(vm, method) {
|
|
6060
5640
|
return value => {
|
|
6061
5641
|
// dispatching new value into the wired method
|
|
@@ -6065,45 +5645,40 @@ function createMethodDataCallback(vm, method) {
|
|
|
6065
5645
|
}, shared.noop);
|
|
6066
5646
|
};
|
|
6067
5647
|
}
|
|
6068
|
-
|
|
6069
5648
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
6070
|
-
let hasPendingConfig = false;
|
|
6071
|
-
|
|
5649
|
+
let hasPendingConfig = false;
|
|
5650
|
+
// creating the reactive observer for reactive params when needed
|
|
6072
5651
|
const ro = createReactiveObserver(() => {
|
|
6073
5652
|
if (hasPendingConfig === false) {
|
|
6074
|
-
hasPendingConfig = true;
|
|
6075
|
-
|
|
5653
|
+
hasPendingConfig = true;
|
|
5654
|
+
// collect new config in the micro-task
|
|
6076
5655
|
Promise.resolve().then(() => {
|
|
6077
|
-
hasPendingConfig = false;
|
|
6078
|
-
|
|
6079
|
-
ro.reset();
|
|
6080
|
-
|
|
5656
|
+
hasPendingConfig = false;
|
|
5657
|
+
// resetting current reactive params
|
|
5658
|
+
ro.reset();
|
|
5659
|
+
// dispatching a new config due to a change in the configuration
|
|
6081
5660
|
computeConfigAndUpdate();
|
|
6082
5661
|
});
|
|
6083
5662
|
}
|
|
6084
5663
|
});
|
|
6085
|
-
|
|
6086
5664
|
const computeConfigAndUpdate = () => {
|
|
6087
5665
|
let config;
|
|
6088
|
-
ro.observe(() => config = configCallback(component));
|
|
5666
|
+
ro.observe(() => config = configCallback(component));
|
|
5667
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
6089
5668
|
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
6090
5669
|
// @ts-ignore it is assigned in the observe() callback
|
|
6091
|
-
|
|
6092
5670
|
callbackWhenConfigIsReady(config);
|
|
6093
5671
|
};
|
|
6094
|
-
|
|
6095
5672
|
return {
|
|
6096
5673
|
computeConfigAndUpdate,
|
|
6097
5674
|
ro
|
|
6098
5675
|
};
|
|
6099
5676
|
}
|
|
6100
|
-
|
|
6101
5677
|
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
6102
5678
|
const {
|
|
6103
5679
|
adapter
|
|
6104
5680
|
} = wireDef;
|
|
6105
5681
|
const adapterContextToken = getAdapterToken(adapter);
|
|
6106
|
-
|
|
6107
5682
|
if (shared.isUndefined(adapterContextToken)) {
|
|
6108
5683
|
return; // no provider found, nothing to be done
|
|
6109
5684
|
}
|
|
@@ -6117,8 +5692,8 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
6117
5692
|
renderer: {
|
|
6118
5693
|
dispatchEvent
|
|
6119
5694
|
}
|
|
6120
|
-
} = vm;
|
|
6121
|
-
|
|
5695
|
+
} = vm;
|
|
5696
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
6122
5697
|
shared.ArrayPush.call(wiredConnecting, () => {
|
|
6123
5698
|
// This event is responsible for connecting the host element with another
|
|
6124
5699
|
// element in the composed path that is providing contextual data. The provider
|
|
@@ -6131,18 +5706,15 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
6131
5706
|
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
6132
5707
|
callbackWhenContextIsReady(newContext);
|
|
6133
5708
|
},
|
|
6134
|
-
|
|
6135
5709
|
setDisconnectedCallback(disconnectCallback) {
|
|
6136
5710
|
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
6137
5711
|
// the the element hosting the wire is disconnected
|
|
6138
5712
|
shared.ArrayPush.call(wiredDisconnecting, disconnectCallback);
|
|
6139
5713
|
}
|
|
6140
|
-
|
|
6141
5714
|
});
|
|
6142
5715
|
dispatchEvent(elm, contextRegistrationEvent);
|
|
6143
5716
|
});
|
|
6144
5717
|
}
|
|
6145
|
-
|
|
6146
5718
|
function createConnector(vm, name, wireDef) {
|
|
6147
5719
|
const {
|
|
6148
5720
|
method,
|
|
@@ -6150,10 +5722,27 @@ function createConnector(vm, name, wireDef) {
|
|
|
6150
5722
|
configCallback,
|
|
6151
5723
|
dynamic
|
|
6152
5724
|
} = wireDef;
|
|
6153
|
-
|
|
5725
|
+
let debugInfo;
|
|
5726
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5727
|
+
const wiredPropOrMethod = shared.isUndefined(method) ? name : method.name;
|
|
5728
|
+
debugInfo = shared.create(null);
|
|
5729
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
5730
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
5731
|
+
}
|
|
5732
|
+
const fieldOrMethodCallback = shared.isUndefined(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
5733
|
+
const dataCallback = value => {
|
|
5734
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5735
|
+
debugInfo.data = value;
|
|
5736
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
5737
|
+
// some conditions in which it does not, ex:
|
|
5738
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
5739
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
5740
|
+
}
|
|
5741
|
+
fieldOrMethodCallback(value);
|
|
5742
|
+
};
|
|
6154
5743
|
let context;
|
|
6155
|
-
let connector;
|
|
6156
|
-
|
|
5744
|
+
let connector;
|
|
5745
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
6157
5746
|
shared.defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
6158
5747
|
value: vm.elm
|
|
6159
5748
|
});
|
|
@@ -6164,41 +5753,41 @@ function createConnector(vm, name, wireDef) {
|
|
|
6164
5753
|
// job
|
|
6165
5754
|
connector = new adapter(dataCallback);
|
|
6166
5755
|
}, shared.noop);
|
|
6167
|
-
|
|
6168
5756
|
const updateConnectorConfig = config => {
|
|
6169
5757
|
// every time the config is recomputed due to tracking,
|
|
6170
5758
|
// this callback will be invoked with the new computed config
|
|
6171
5759
|
runWithBoundaryProtection(vm, vm, shared.noop, () => {
|
|
6172
5760
|
// job
|
|
5761
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5762
|
+
debugInfo.config = config;
|
|
5763
|
+
debugInfo.context = context;
|
|
5764
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
5765
|
+
}
|
|
6173
5766
|
connector.update(config, context);
|
|
6174
5767
|
}, shared.noop);
|
|
6175
|
-
};
|
|
5768
|
+
};
|
|
5769
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
6176
5770
|
// If it has params, we will need to observe changes in the next tick.
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
5771
|
const {
|
|
6180
5772
|
computeConfigAndUpdate,
|
|
6181
5773
|
ro
|
|
6182
|
-
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
6183
|
-
|
|
5774
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
5775
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
6184
5776
|
if (!shared.isUndefined(adapter.contextSchema)) {
|
|
6185
5777
|
createContextWatcher(vm, wireDef, newContext => {
|
|
6186
5778
|
// every time the context is pushed into this component,
|
|
6187
5779
|
// this callback will be invoked with the new computed context
|
|
6188
5780
|
if (context !== newContext) {
|
|
6189
|
-
context = newContext;
|
|
5781
|
+
context = newContext;
|
|
5782
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
6190
5783
|
// context, this is to preserve the identity characteristics, config should not have identity
|
|
6191
5784
|
// (ever), while context can have identity
|
|
6192
|
-
|
|
6193
|
-
if (vm.state === 1
|
|
6194
|
-
/* VMState.connected */
|
|
6195
|
-
) {
|
|
5785
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
6196
5786
|
computeConfigAndUpdate();
|
|
6197
5787
|
}
|
|
6198
5788
|
}
|
|
6199
5789
|
});
|
|
6200
5790
|
}
|
|
6201
|
-
|
|
6202
5791
|
return {
|
|
6203
5792
|
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
6204
5793
|
connector,
|
|
@@ -6206,7 +5795,6 @@ function createConnector(vm, name, wireDef) {
|
|
|
6206
5795
|
resetConfigWatcher: () => ro.reset()
|
|
6207
5796
|
};
|
|
6208
5797
|
}
|
|
6209
|
-
|
|
6210
5798
|
const AdapterToTokenMap = new Map();
|
|
6211
5799
|
function getAdapterToken(adapter) {
|
|
6212
5800
|
return AdapterToTokenMap.get(adapter);
|
|
@@ -6219,7 +5807,6 @@ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
|
6219
5807
|
if (adapter.adapter) {
|
|
6220
5808
|
adapter = adapter.adapter;
|
|
6221
5809
|
}
|
|
6222
|
-
|
|
6223
5810
|
const method = descriptor.value;
|
|
6224
5811
|
const def = {
|
|
6225
5812
|
adapter,
|
|
@@ -6234,7 +5821,6 @@ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
|
6234
5821
|
if (adapter.adapter) {
|
|
6235
5822
|
adapter = adapter.adapter;
|
|
6236
5823
|
}
|
|
6237
|
-
|
|
6238
5824
|
const def = {
|
|
6239
5825
|
adapter,
|
|
6240
5826
|
configCallback,
|
|
@@ -6249,17 +5835,17 @@ function installWireAdapters(vm) {
|
|
|
6249
5835
|
wire
|
|
6250
5836
|
}
|
|
6251
5837
|
} = vm;
|
|
5838
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5839
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = shared.create(null);
|
|
5840
|
+
}
|
|
6252
5841
|
const wiredConnecting = context.wiredConnecting = [];
|
|
6253
5842
|
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
6254
|
-
|
|
6255
5843
|
for (const fieldNameOrMethod in wire) {
|
|
6256
5844
|
const descriptor = wire[fieldNameOrMethod];
|
|
6257
5845
|
const wireDef = WireMetaMap.get(descriptor);
|
|
6258
|
-
|
|
6259
5846
|
if (process.env.NODE_ENV !== 'production') {
|
|
6260
5847
|
shared.assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
6261
5848
|
}
|
|
6262
|
-
|
|
6263
5849
|
if (!shared.isUndefined(wireDef)) {
|
|
6264
5850
|
const {
|
|
6265
5851
|
connector,
|
|
@@ -6269,14 +5855,12 @@ function installWireAdapters(vm) {
|
|
|
6269
5855
|
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
6270
5856
|
shared.ArrayPush.call(wiredConnecting, () => {
|
|
6271
5857
|
connector.connect();
|
|
6272
|
-
|
|
6273
5858
|
if (!features.lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
6274
5859
|
if (hasDynamicParams) {
|
|
6275
5860
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
6276
5861
|
return;
|
|
6277
5862
|
}
|
|
6278
5863
|
}
|
|
6279
|
-
|
|
6280
5864
|
computeConfigAndUpdate();
|
|
6281
5865
|
});
|
|
6282
5866
|
shared.ArrayPush.call(wiredDisconnecting, () => {
|
|
@@ -6290,7 +5874,6 @@ function connectWireAdapters(vm) {
|
|
|
6290
5874
|
const {
|
|
6291
5875
|
wiredConnecting
|
|
6292
5876
|
} = vm.context;
|
|
6293
|
-
|
|
6294
5877
|
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
6295
5878
|
wiredConnecting[i]();
|
|
6296
5879
|
}
|
|
@@ -6942,4 +6525,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6942
6525
|
exports.track = track;
|
|
6943
6526
|
exports.unwrap = unwrap;
|
|
6944
6527
|
exports.wire = wire;
|
|
6945
|
-
/* version: 2.
|
|
6528
|
+
/* version: 2.30.1 */
|