lwc 2.25.1 → 2.27.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-dom/esm/es2017/engine-dom.js +953 -431
- package/dist/engine-dom/iife/es2017/engine-dom.js +953 -431
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +797 -223
- package/dist/engine-dom/iife/es5/engine-dom.js +1025 -330
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +952 -241
- package/dist/engine-dom/umd/es2017/engine-dom.js +953 -431
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +797 -223
- package/dist/engine-dom/umd/es5/engine-dom.js +1025 -330
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +952 -241
- package/dist/engine-server/commonjs/es2017/engine-server.js +201 -247
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +201 -247
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +4 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4 -4
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*/
|
|
50
50
|
const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
|
|
51
51
|
const { isArray: isArray$1 } = Array;
|
|
52
|
-
const { copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
|
|
52
|
+
const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
|
|
53
53
|
const { fromCharCode: StringFromCharCode } = String;
|
|
54
54
|
const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
|
55
55
|
function isUndefined$1(obj) {
|
|
@@ -305,9 +305,9 @@
|
|
|
305
305
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
306
306
|
*/
|
|
307
307
|
// Increment whenever the LWC template compiler changes
|
|
308
|
-
const LWC_VERSION = "2.
|
|
308
|
+
const LWC_VERSION = "2.27.0";
|
|
309
309
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
310
|
-
/** version: 2.
|
|
310
|
+
/** version: 2.27.0 */
|
|
311
311
|
|
|
312
312
|
/**
|
|
313
313
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
patch$1(propName);
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
/** version: 2.
|
|
392
|
+
/** version: 2.27.0 */
|
|
393
393
|
|
|
394
394
|
/**
|
|
395
395
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -405,7 +405,6 @@
|
|
|
405
405
|
DUMMY_TEST_FLAG: null,
|
|
406
406
|
ENABLE_ELEMENT_PATCH: null,
|
|
407
407
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
408
|
-
ENABLE_HMR: null,
|
|
409
408
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
410
409
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
411
410
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
@@ -416,6 +415,7 @@
|
|
|
416
415
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
417
416
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
418
417
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
418
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
419
419
|
};
|
|
420
420
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
421
421
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -469,7 +469,7 @@
|
|
|
469
469
|
setFeatureFlag(name, value);
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
/** version: 2.
|
|
472
|
+
/** version: 2.27.0 */
|
|
473
473
|
|
|
474
474
|
/*
|
|
475
475
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1943,7 +1943,9 @@
|
|
|
1943
1943
|
const LightningElement = function () {
|
|
1944
1944
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1945
1945
|
if (isNull(vmBeingConstructed)) {
|
|
1946
|
-
|
|
1946
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1947
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1948
|
+
throw new TypeError('Illegal constructor');
|
|
1947
1949
|
}
|
|
1948
1950
|
const vm = vmBeingConstructed;
|
|
1949
1951
|
const { def, elm } = vm;
|
|
@@ -2992,274 +2994,213 @@
|
|
|
2992
2994
|
const activeTemplates = new WeakMap();
|
|
2993
2995
|
const activeComponents = new WeakMap();
|
|
2994
2996
|
const activeStyles = new WeakMap();
|
|
2995
|
-
|
|
2996
2997
|
function rehydrateHotTemplate(tpl) {
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
return true;
|
|
2998
|
+
const list = activeTemplates.get(tpl);
|
|
2999
|
+
if (!isUndefined$1(list)) {
|
|
3000
|
+
list.forEach((vm) => {
|
|
3001
|
+
if (isFalse(vm.isDirty)) {
|
|
3002
|
+
// forcing the vm to rehydrate in the micro-task:
|
|
3003
|
+
markComponentAsDirty(vm);
|
|
3004
|
+
scheduleRehydration(vm);
|
|
3005
|
+
}
|
|
3006
|
+
});
|
|
3007
|
+
// resetting the Set to release the memory of those vm references
|
|
3008
|
+
// since they are not longer related to this template, instead
|
|
3009
|
+
// they will get re-associated once these instances are rehydrated.
|
|
3010
|
+
list.clear();
|
|
3011
|
+
}
|
|
3012
|
+
return true;
|
|
3014
3013
|
}
|
|
3015
|
-
|
|
3016
3014
|
function rehydrateHotStyle(style) {
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
return true;
|
|
3015
|
+
const list = activeStyles.get(style);
|
|
3016
|
+
if (!isUndefined$1(list)) {
|
|
3017
|
+
list.forEach((vm) => {
|
|
3018
|
+
// if a style definition is swapped, we must reset
|
|
3019
|
+
// vm's template content in the next micro-task:
|
|
3020
|
+
forceRehydration(vm);
|
|
3021
|
+
});
|
|
3022
|
+
// resetting the Set to release the memory of those vm references
|
|
3023
|
+
// since they are not longer related to this style, instead
|
|
3024
|
+
// they will get re-associated once these instances are rehydrated.
|
|
3025
|
+
list.clear();
|
|
3026
|
+
}
|
|
3027
|
+
return true;
|
|
3032
3028
|
}
|
|
3033
|
-
|
|
3034
3029
|
function rehydrateHotComponent(Ctor) {
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
list.clear();
|
|
3062
|
-
}
|
|
3063
|
-
|
|
3064
|
-
return canRefreshAllInstances;
|
|
3030
|
+
const list = activeComponents.get(Ctor);
|
|
3031
|
+
let canRefreshAllInstances = true;
|
|
3032
|
+
if (!isUndefined$1(list)) {
|
|
3033
|
+
list.forEach((vm) => {
|
|
3034
|
+
const { owner } = vm;
|
|
3035
|
+
if (!isNull(owner)) {
|
|
3036
|
+
// if a component class definition is swapped, we must reset
|
|
3037
|
+
// owner's template content in the next micro-task:
|
|
3038
|
+
forceRehydration(owner);
|
|
3039
|
+
}
|
|
3040
|
+
else {
|
|
3041
|
+
// the hot swapping for components only work for instances of components
|
|
3042
|
+
// created from a template, root elements can't be swapped because we
|
|
3043
|
+
// don't have a way to force the creation of the element with the same state
|
|
3044
|
+
// of the current element.
|
|
3045
|
+
// Instead, we can report the problem to the caller so it can take action,
|
|
3046
|
+
// for example: reload the entire page.
|
|
3047
|
+
canRefreshAllInstances = false;
|
|
3048
|
+
}
|
|
3049
|
+
});
|
|
3050
|
+
// resetting the Set to release the memory of those vm references
|
|
3051
|
+
// since they are not longer related to this constructor, instead
|
|
3052
|
+
// they will get re-associated once these instances are rehydrated.
|
|
3053
|
+
list.clear();
|
|
3054
|
+
}
|
|
3055
|
+
return canRefreshAllInstances;
|
|
3065
3056
|
}
|
|
3066
|
-
|
|
3067
3057
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3058
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3059
|
+
// this method should never leak to prod
|
|
3060
|
+
throw new ReferenceError();
|
|
3061
|
+
}
|
|
3074
3062
|
const visited = new Set();
|
|
3075
|
-
|
|
3076
3063
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
3077
|
-
|
|
3078
|
-
|
|
3064
|
+
visited.add(tpl);
|
|
3065
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
3079
3066
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
return tpl;
|
|
3067
|
+
return tpl;
|
|
3083
3068
|
}
|
|
3084
3069
|
function getComponentOrSwappedComponent(Ctor) {
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3070
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3071
|
+
// this method should never leak to prod
|
|
3072
|
+
throw new ReferenceError();
|
|
3073
|
+
}
|
|
3091
3074
|
const visited = new Set();
|
|
3092
|
-
|
|
3093
3075
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
3094
|
-
|
|
3095
|
-
|
|
3076
|
+
visited.add(Ctor);
|
|
3077
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
3096
3078
|
}
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
return Ctor;
|
|
3079
|
+
return Ctor;
|
|
3100
3080
|
}
|
|
3101
3081
|
function getStyleOrSwappedStyle(style) {
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3082
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3083
|
+
// this method should never leak to prod
|
|
3084
|
+
throw new ReferenceError();
|
|
3085
|
+
}
|
|
3108
3086
|
const visited = new Set();
|
|
3109
|
-
|
|
3110
3087
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
3111
|
-
|
|
3112
|
-
|
|
3088
|
+
visited.add(style);
|
|
3089
|
+
style = swappedStyleMap.get(style);
|
|
3113
3090
|
}
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
return style;
|
|
3091
|
+
return style;
|
|
3117
3092
|
}
|
|
3118
3093
|
function setActiveVM(vm) {
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3094
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3095
|
+
// this method should never leak to prod
|
|
3096
|
+
throw new ReferenceError();
|
|
3097
|
+
}
|
|
3125
3098
|
// tracking active component
|
|
3126
3099
|
const Ctor = vm.def.ctor;
|
|
3127
3100
|
let componentVMs = activeComponents.get(Ctor);
|
|
3128
|
-
|
|
3129
3101
|
if (isUndefined$1(componentVMs)) {
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
}
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3102
|
+
componentVMs = new Set();
|
|
3103
|
+
activeComponents.set(Ctor, componentVMs);
|
|
3104
|
+
}
|
|
3105
|
+
// this will allow us to keep track of the hot components
|
|
3106
|
+
componentVMs.add(vm);
|
|
3107
|
+
// tracking active template
|
|
3137
3108
|
const tpl = vm.cmpTemplate;
|
|
3138
|
-
|
|
3139
3109
|
if (tpl) {
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
stylesheetVMs.add(vm);
|
|
3170
|
-
});
|
|
3171
|
-
}
|
|
3110
|
+
let templateVMs = activeTemplates.get(tpl);
|
|
3111
|
+
if (isUndefined$1(templateVMs)) {
|
|
3112
|
+
templateVMs = new Set();
|
|
3113
|
+
activeTemplates.set(tpl, templateVMs);
|
|
3114
|
+
}
|
|
3115
|
+
// this will allow us to keep track of the templates that are
|
|
3116
|
+
// being used by a hot component
|
|
3117
|
+
templateVMs.add(vm);
|
|
3118
|
+
// tracking active styles associated to template
|
|
3119
|
+
const stylesheets = tpl.stylesheets;
|
|
3120
|
+
if (!isUndefined$1(stylesheets)) {
|
|
3121
|
+
flattenStylesheets(stylesheets).forEach((stylesheet) => {
|
|
3122
|
+
// this is necessary because we don't hold the list of styles
|
|
3123
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
3124
|
+
// but the styles attached to the template might not be the actual
|
|
3125
|
+
// active ones, but the swapped versions of those.
|
|
3126
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3127
|
+
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
3128
|
+
if (isUndefined$1(stylesheetVMs)) {
|
|
3129
|
+
stylesheetVMs = new Set();
|
|
3130
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
3131
|
+
}
|
|
3132
|
+
// this will allow us to keep track of the stylesheet that are
|
|
3133
|
+
// being used by a hot component
|
|
3134
|
+
stylesheetVMs.add(vm);
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3172
3137
|
}
|
|
3173
|
-
}
|
|
3174
3138
|
}
|
|
3175
3139
|
function removeActiveVM(vm) {
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3140
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3141
|
+
// this method should never leak to prod
|
|
3142
|
+
throw new ReferenceError();
|
|
3143
|
+
}
|
|
3182
3144
|
// tracking inactive component
|
|
3183
3145
|
const Ctor = vm.def.ctor;
|
|
3184
3146
|
let list = activeComponents.get(Ctor);
|
|
3185
|
-
|
|
3186
3147
|
if (!isUndefined$1(list)) {
|
|
3187
|
-
// deleting the vm from the set to avoid leaking memory
|
|
3188
|
-
list.delete(vm);
|
|
3189
|
-
} // removing inactive template
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
const tpl = vm.cmpTemplate;
|
|
3193
|
-
|
|
3194
|
-
if (tpl) {
|
|
3195
|
-
list = activeTemplates.get(tpl);
|
|
3196
|
-
|
|
3197
|
-
if (!isUndefined$1(list)) {
|
|
3198
3148
|
// deleting the vm from the set to avoid leaking memory
|
|
3199
3149
|
list.delete(vm);
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
flattenStylesheets(styles).forEach(style => {
|
|
3207
|
-
list = activeStyles.get(style);
|
|
3208
|
-
|
|
3209
|
-
if (!isUndefined$1(list)) {
|
|
3150
|
+
}
|
|
3151
|
+
// removing inactive template
|
|
3152
|
+
const tpl = vm.cmpTemplate;
|
|
3153
|
+
if (tpl) {
|
|
3154
|
+
list = activeTemplates.get(tpl);
|
|
3155
|
+
if (!isUndefined$1(list)) {
|
|
3210
3156
|
// deleting the vm from the set to avoid leaking memory
|
|
3211
3157
|
list.delete(vm);
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3158
|
+
}
|
|
3159
|
+
// removing active styles associated to template
|
|
3160
|
+
const styles = tpl.stylesheets;
|
|
3161
|
+
if (!isUndefined$1(styles)) {
|
|
3162
|
+
flattenStylesheets(styles).forEach((style) => {
|
|
3163
|
+
list = activeStyles.get(style);
|
|
3164
|
+
if (!isUndefined$1(list)) {
|
|
3165
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3166
|
+
list.delete(vm);
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
}
|
|
3215
3170
|
}
|
|
3216
|
-
}
|
|
3217
3171
|
}
|
|
3218
3172
|
function swapTemplate(oldTpl, newTpl) {
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3173
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3174
|
+
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
3175
|
+
swappedTemplateMap.set(oldTpl, newTpl);
|
|
3176
|
+
return rehydrateHotTemplate(oldTpl);
|
|
3177
|
+
}
|
|
3178
|
+
else {
|
|
3179
|
+
throw new TypeError(`Invalid Template`);
|
|
3180
|
+
}
|
|
3225
3181
|
}
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3229
|
-
throw new Error('HMR is not enabled');
|
|
3230
|
-
}
|
|
3231
|
-
|
|
3232
|
-
return false;
|
|
3182
|
+
return false;
|
|
3233
3183
|
}
|
|
3234
3184
|
function swapComponent(oldComponent, newComponent) {
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3185
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3186
|
+
if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
|
|
3187
|
+
swappedComponentMap.set(oldComponent, newComponent);
|
|
3188
|
+
return rehydrateHotComponent(oldComponent);
|
|
3189
|
+
}
|
|
3190
|
+
else {
|
|
3191
|
+
throw new TypeError(`Invalid Component`);
|
|
3192
|
+
}
|
|
3241
3193
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3245
|
-
throw new Error('HMR is not enabled');
|
|
3246
|
-
}
|
|
3247
|
-
|
|
3248
|
-
return false;
|
|
3194
|
+
return false;
|
|
3249
3195
|
}
|
|
3250
3196
|
function swapStyle(oldStyle, newStyle) {
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3259
|
-
throw new Error('HMR is not enabled');
|
|
3260
|
-
}
|
|
3261
|
-
|
|
3262
|
-
return false;
|
|
3197
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3198
|
+
// TODO [#1887]: once the support for registering styles is implemented
|
|
3199
|
+
// we can add the validation of both styles around this block.
|
|
3200
|
+
swappedStyleMap.set(oldStyle, newStyle);
|
|
3201
|
+
return rehydrateHotStyle(oldStyle);
|
|
3202
|
+
}
|
|
3203
|
+
return false;
|
|
3263
3204
|
}
|
|
3264
3205
|
|
|
3265
3206
|
/*
|
|
@@ -3670,15 +3611,18 @@
|
|
|
3670
3611
|
/**
|
|
3671
3612
|
* This function returns the host style token for a custom element if it
|
|
3672
3613
|
* exists. Otherwise it returns null.
|
|
3614
|
+
*
|
|
3615
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3673
3616
|
*/
|
|
3674
3617
|
|
|
3675
3618
|
function getStylesheetTokenHost(vnode) {
|
|
3676
3619
|
const {
|
|
3677
|
-
template
|
|
3678
|
-
stylesheetToken
|
|
3679
|
-
}
|
|
3620
|
+
template
|
|
3680
3621
|
} = getComponentInternalDef(vnode.ctor);
|
|
3681
|
-
|
|
3622
|
+
const {
|
|
3623
|
+
stylesheetToken
|
|
3624
|
+
} = template;
|
|
3625
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3682
3626
|
}
|
|
3683
3627
|
|
|
3684
3628
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -3732,75 +3676,6 @@
|
|
|
3732
3676
|
return null;
|
|
3733
3677
|
}
|
|
3734
3678
|
|
|
3735
|
-
/*
|
|
3736
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
3737
|
-
* All rights reserved.
|
|
3738
|
-
* SPDX-License-Identifier: MIT
|
|
3739
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3740
|
-
*/
|
|
3741
|
-
|
|
3742
|
-
function checkHasVM(elm) {
|
|
3743
|
-
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3744
|
-
|
|
3745
|
-
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3746
|
-
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3747
|
-
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3748
|
-
logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
|
|
3749
|
-
}
|
|
3750
|
-
|
|
3751
|
-
return hasVM;
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
3755
|
-
const {
|
|
3756
|
-
getCustomElement,
|
|
3757
|
-
HTMLElementExported: RendererHTMLElement,
|
|
3758
|
-
defineCustomElement
|
|
3759
|
-
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3760
|
-
// produce only tags with lowercase letters
|
|
3761
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
3762
|
-
|
|
3763
|
-
tagName = tagName.toLowerCase();
|
|
3764
|
-
let CE = getCustomElement(tagName);
|
|
3765
|
-
|
|
3766
|
-
if (!isUndefined$1(CE)) {
|
|
3767
|
-
return CE;
|
|
3768
|
-
}
|
|
3769
|
-
/**
|
|
3770
|
-
* LWC Upgradable Element reference to an element that was created
|
|
3771
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3772
|
-
*/
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3776
|
-
constructor(upgradeCallback) {
|
|
3777
|
-
super();
|
|
3778
|
-
|
|
3779
|
-
if (isFunction$1(upgradeCallback)) {
|
|
3780
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3781
|
-
}
|
|
3782
|
-
}
|
|
3783
|
-
|
|
3784
|
-
};
|
|
3785
|
-
|
|
3786
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3787
|
-
CE.prototype.connectedCallback = function () {
|
|
3788
|
-
if (checkHasVM(this)) {
|
|
3789
|
-
connectRootElement(this);
|
|
3790
|
-
}
|
|
3791
|
-
};
|
|
3792
|
-
|
|
3793
|
-
CE.prototype.disconnectedCallback = function () {
|
|
3794
|
-
if (checkHasVM(this)) {
|
|
3795
|
-
disconnectRootElement(this);
|
|
3796
|
-
}
|
|
3797
|
-
};
|
|
3798
|
-
}
|
|
3799
|
-
|
|
3800
|
-
defineCustomElement(tagName, CE);
|
|
3801
|
-
return CE;
|
|
3802
|
-
}
|
|
3803
|
-
|
|
3804
3679
|
/*
|
|
3805
3680
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3806
3681
|
* All rights reserved.
|
|
@@ -3817,6 +3692,9 @@
|
|
|
3817
3692
|
function isVCustomElement(vnode) {
|
|
3818
3693
|
return vnode.type === 3 /* VNodeType.CustomElement */;
|
|
3819
3694
|
}
|
|
3695
|
+
function isVScopedSlotFragment(vnode) {
|
|
3696
|
+
return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
|
|
3697
|
+
}
|
|
3820
3698
|
|
|
3821
3699
|
/*
|
|
3822
3700
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4314,7 +4192,9 @@
|
|
|
4314
4192
|
sel,
|
|
4315
4193
|
owner
|
|
4316
4194
|
} = vnode;
|
|
4317
|
-
const
|
|
4195
|
+
const {
|
|
4196
|
+
createCustomElement
|
|
4197
|
+
} = renderer;
|
|
4318
4198
|
/**
|
|
4319
4199
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4320
4200
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -4323,10 +4203,25 @@
|
|
|
4323
4203
|
*/
|
|
4324
4204
|
|
|
4325
4205
|
let vm;
|
|
4326
|
-
|
|
4206
|
+
|
|
4207
|
+
const upgradeCallback = elm => {
|
|
4327
4208
|
// the custom element from the registry is expecting an upgrade callback
|
|
4328
4209
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
4329
|
-
}
|
|
4210
|
+
};
|
|
4211
|
+
|
|
4212
|
+
const connectedCallback = elm => {
|
|
4213
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4214
|
+
connectRootElement(elm);
|
|
4215
|
+
}
|
|
4216
|
+
};
|
|
4217
|
+
|
|
4218
|
+
const disconnectedCallback = elm => {
|
|
4219
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4220
|
+
disconnectRootElement(elm);
|
|
4221
|
+
}
|
|
4222
|
+
};
|
|
4223
|
+
|
|
4224
|
+
const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
4330
4225
|
vnode.elm = elm;
|
|
4331
4226
|
vnode.vm = vm;
|
|
4332
4227
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -4334,8 +4229,6 @@
|
|
|
4334
4229
|
|
|
4335
4230
|
if (vm) {
|
|
4336
4231
|
allocateChildren(vnode, vm);
|
|
4337
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4338
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
4339
4232
|
}
|
|
4340
4233
|
|
|
4341
4234
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -4636,7 +4529,7 @@
|
|
|
4636
4529
|
/* RenderMode.Light */
|
|
4637
4530
|
) {
|
|
4638
4531
|
// slow path
|
|
4639
|
-
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
4532
|
+
allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
|
|
4640
4533
|
|
|
4641
4534
|
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4642
4535
|
|
|
@@ -4672,13 +4565,19 @@
|
|
|
4672
4565
|
return vm;
|
|
4673
4566
|
}
|
|
4674
4567
|
|
|
4675
|
-
function allocateInSlot(vm, children) {
|
|
4676
|
-
var _a;
|
|
4568
|
+
function allocateInSlot(vm, children, owner) {
|
|
4569
|
+
var _a, _b;
|
|
4677
4570
|
|
|
4678
4571
|
const {
|
|
4679
|
-
cmpSlots:
|
|
4572
|
+
cmpSlots: {
|
|
4573
|
+
slotAssignments: oldSlotsMapping
|
|
4574
|
+
}
|
|
4680
4575
|
} = vm;
|
|
4681
|
-
const
|
|
4576
|
+
const cmpSlotsMapping = create(null);
|
|
4577
|
+
vm.cmpSlots = {
|
|
4578
|
+
owner,
|
|
4579
|
+
slotAssignments: cmpSlotsMapping
|
|
4580
|
+
};
|
|
4682
4581
|
|
|
4683
4582
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4684
4583
|
const vnode = children[i];
|
|
@@ -4690,19 +4589,21 @@
|
|
|
4690
4589
|
let slotName = '';
|
|
4691
4590
|
|
|
4692
4591
|
if (isVBaseElement(vnode)) {
|
|
4693
|
-
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot)
|
|
4592
|
+
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4593
|
+
} else if (isVScopedSlotFragment(vnode)) {
|
|
4594
|
+
slotName = vnode.slotName;
|
|
4694
4595
|
}
|
|
4695
4596
|
|
|
4696
|
-
const vnodes =
|
|
4597
|
+
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4697
4598
|
ArrayPush$1.call(vnodes, vnode);
|
|
4698
4599
|
}
|
|
4699
4600
|
|
|
4700
4601
|
if (isFalse(vm.isDirty)) {
|
|
4701
4602
|
// We need to determine if the old allocation is really different from the new one
|
|
4702
4603
|
// and mark the vm as dirty
|
|
4703
|
-
const oldKeys = keys(
|
|
4604
|
+
const oldKeys = keys(oldSlotsMapping);
|
|
4704
4605
|
|
|
4705
|
-
if (oldKeys.length !== keys(
|
|
4606
|
+
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
4706
4607
|
markComponentAsDirty(vm);
|
|
4707
4608
|
return;
|
|
4708
4609
|
}
|
|
@@ -4710,15 +4611,15 @@
|
|
|
4710
4611
|
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4711
4612
|
const key = oldKeys[i];
|
|
4712
4613
|
|
|
4713
|
-
if (isUndefined$1(
|
|
4614
|
+
if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4714
4615
|
markComponentAsDirty(vm);
|
|
4715
4616
|
return;
|
|
4716
4617
|
}
|
|
4717
4618
|
|
|
4718
|
-
const oldVNodes =
|
|
4719
|
-
const vnodes =
|
|
4619
|
+
const oldVNodes = oldSlotsMapping[key];
|
|
4620
|
+
const vnodes = cmpSlotsMapping[key];
|
|
4720
4621
|
|
|
4721
|
-
for (let j = 0, a =
|
|
4622
|
+
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4722
4623
|
if (oldVNodes[j] !== vnodes[j]) {
|
|
4723
4624
|
markComponentAsDirty(vm);
|
|
4724
4625
|
return;
|
|
@@ -4918,6 +4819,18 @@
|
|
|
4918
4819
|
function addVNodeToChildLWC(vnode) {
|
|
4919
4820
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
4920
4821
|
}
|
|
4822
|
+
// [s]coped [s]lot [f]actory
|
|
4823
|
+
function ssf(slotName, factory) {
|
|
4824
|
+
return {
|
|
4825
|
+
type: 6 /* VNodeType.ScopedSlotFragment */,
|
|
4826
|
+
factory,
|
|
4827
|
+
owner: getVMBeingRendered(),
|
|
4828
|
+
elm: undefined,
|
|
4829
|
+
sel: undefined,
|
|
4830
|
+
key: undefined,
|
|
4831
|
+
slotName,
|
|
4832
|
+
};
|
|
4833
|
+
}
|
|
4921
4834
|
// [st]atic node
|
|
4922
4835
|
function st(fragment, key) {
|
|
4923
4836
|
return {
|
|
@@ -5001,9 +4914,31 @@
|
|
|
5001
4914
|
assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
|
|
5002
4915
|
}
|
|
5003
4916
|
if (!isUndefined$1(slotset) &&
|
|
5004
|
-
!isUndefined$1(slotset
|
|
5005
|
-
slotset[slotName]
|
|
5006
|
-
|
|
4917
|
+
!isUndefined$1(slotset.slotAssignments) &&
|
|
4918
|
+
!isUndefined$1(slotset.slotAssignments[slotName]) &&
|
|
4919
|
+
slotset.slotAssignments[slotName].length !== 0) {
|
|
4920
|
+
children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
|
|
4921
|
+
// If the passed slot content is factory, evaluate it and use the produced vnodes
|
|
4922
|
+
if (vnode && isVScopedSlotFragment(vnode)) {
|
|
4923
|
+
const vmBeingRenderedInception = getVMBeingRendered();
|
|
4924
|
+
let children = [];
|
|
4925
|
+
// Evaluate in the scope of the slot content's owner
|
|
4926
|
+
// if a slotset is provided, there will always be an owner. The only case where owner is
|
|
4927
|
+
// undefined is for root components, but root components cannot accept slotted content
|
|
4928
|
+
setVMBeingRendered(slotset.owner);
|
|
4929
|
+
try {
|
|
4930
|
+
children = vnode.factory(data.slotData);
|
|
4931
|
+
}
|
|
4932
|
+
finally {
|
|
4933
|
+
setVMBeingRendered(vmBeingRenderedInception);
|
|
4934
|
+
}
|
|
4935
|
+
return ArrayConcat$1.call(acc, children);
|
|
4936
|
+
}
|
|
4937
|
+
else {
|
|
4938
|
+
// If the slot content is a static list of child nodes provided by the parent, nothing to do
|
|
4939
|
+
return ArrayConcat$1.call(acc, vnode);
|
|
4940
|
+
}
|
|
4941
|
+
}, []);
|
|
5007
4942
|
}
|
|
5008
4943
|
const vmBeingRendered = getVMBeingRendered();
|
|
5009
4944
|
const { renderMode, shadowMode } = vmBeingRendered;
|
|
@@ -5323,6 +5258,7 @@
|
|
|
5323
5258
|
gid,
|
|
5324
5259
|
fid,
|
|
5325
5260
|
shc,
|
|
5261
|
+
ssf,
|
|
5326
5262
|
});
|
|
5327
5263
|
|
|
5328
5264
|
/*
|
|
@@ -5459,9 +5395,9 @@
|
|
|
5459
5395
|
}
|
|
5460
5396
|
const { cmpSlots } = vm;
|
|
5461
5397
|
const { slots = EmptyArray } = html;
|
|
5462
|
-
for (const slotName in cmpSlots) {
|
|
5398
|
+
for (const slotName in cmpSlots.slotAssignments) {
|
|
5463
5399
|
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
5464
|
-
assert.isTrue(isArray$1(cmpSlots[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
5400
|
+
assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
5465
5401
|
if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
|
|
5466
5402
|
// TODO [#1297]: this should never really happen because the compiler should always validate
|
|
5467
5403
|
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
@@ -5958,7 +5894,9 @@
|
|
|
5958
5894
|
velements: EmptyArray,
|
|
5959
5895
|
cmpProps: create(null),
|
|
5960
5896
|
cmpFields: create(null),
|
|
5961
|
-
cmpSlots:
|
|
5897
|
+
cmpSlots: {
|
|
5898
|
+
slotAssignments: create(null)
|
|
5899
|
+
},
|
|
5962
5900
|
oar: create(null),
|
|
5963
5901
|
cmpTemplate: null,
|
|
5964
5902
|
hydrated: Boolean(hydrated),
|
|
@@ -7109,19 +7047,23 @@
|
|
|
7109
7047
|
//
|
|
7110
7048
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
7111
7049
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
7112
|
-
if (scopedToken) {
|
|
7050
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
7113
7051
|
if (!isUndefined$1(className)) {
|
|
7114
|
-
className
|
|
7115
|
-
|
|
7116
|
-
|
|
7052
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
7053
|
+
const classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
7054
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
7055
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
7117
7056
|
}
|
|
7118
7057
|
else if (!isUndefined$1(classMap)) {
|
|
7119
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {
|
|
7058
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
|
|
7120
7059
|
}
|
|
7121
7060
|
else {
|
|
7122
|
-
className
|
|
7123
|
-
|
|
7124
|
-
|
|
7061
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
7062
|
+
const classTokens = [scopedToken, stylesheetTokenHost];
|
|
7063
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
7064
|
+
if (classNames.length) {
|
|
7065
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
7066
|
+
}
|
|
7125
7067
|
}
|
|
7126
7068
|
}
|
|
7127
7069
|
let nodesAreCompatible = true;
|
|
@@ -7363,7 +7305,7 @@
|
|
|
7363
7305
|
}
|
|
7364
7306
|
return ctor;
|
|
7365
7307
|
}
|
|
7366
|
-
/* version: 2.
|
|
7308
|
+
/* version: 2.27.0 */
|
|
7367
7309
|
|
|
7368
7310
|
/*
|
|
7369
7311
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7507,6 +7449,626 @@
|
|
|
7507
7449
|
}
|
|
7508
7450
|
}
|
|
7509
7451
|
|
|
7452
|
+
/*
|
|
7453
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
7454
|
+
* All rights reserved.
|
|
7455
|
+
* SPDX-License-Identifier: MIT
|
|
7456
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7457
|
+
*/
|
|
7458
|
+
function isCustomElementRegistryAvailable() {
|
|
7459
|
+
if (typeof customElements === 'undefined') {
|
|
7460
|
+
return false;
|
|
7461
|
+
}
|
|
7462
|
+
try {
|
|
7463
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
7464
|
+
// _wrapNativeSuper()
|
|
7465
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
|
|
7466
|
+
// get wrapped by babel.
|
|
7467
|
+
const HTMLElementAlias = HTMLElement;
|
|
7468
|
+
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7469
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7470
|
+
// which are not equipped to be initialized that way.
|
|
7471
|
+
class clazz extends HTMLElementAlias {
|
|
7472
|
+
}
|
|
7473
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7474
|
+
new clazz();
|
|
7475
|
+
return true;
|
|
7476
|
+
}
|
|
7477
|
+
catch (_a) {
|
|
7478
|
+
return false;
|
|
7479
|
+
}
|
|
7480
|
+
}
|
|
7481
|
+
const hasCustomElements = isCustomElementRegistryAvailable();
|
|
7482
|
+
|
|
7483
|
+
/*
|
|
7484
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7485
|
+
* All rights reserved.
|
|
7486
|
+
* SPDX-License-Identifier: MIT
|
|
7487
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7488
|
+
*/
|
|
7489
|
+
// Creates a custom element for compat (legacy) browser environments
|
|
7490
|
+
const createCustomElementCompat = (tagName, upgradeCallback) => {
|
|
7491
|
+
const elm = document.createElement(tagName);
|
|
7492
|
+
upgradeCallback(elm); // nothing to do with the result for now
|
|
7493
|
+
return elm;
|
|
7494
|
+
};
|
|
7495
|
+
|
|
7496
|
+
/*
|
|
7497
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7498
|
+
* All rights reserved.
|
|
7499
|
+
* SPDX-License-Identifier: MIT
|
|
7500
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7501
|
+
*/
|
|
7502
|
+
const cachedConstructors = new Map();
|
|
7503
|
+
const elementsUpgradedOutsideLWC = new WeakSet();
|
|
7504
|
+
let elementBeingUpgradedByLWC = false;
|
|
7505
|
+
// Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
|
|
7506
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
|
7507
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
|
7508
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
|
7509
|
+
// This class should be created once per tag name.
|
|
7510
|
+
const createUpgradableConstructor = (connectedCallback, disconnectedCallback) => {
|
|
7511
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
7512
|
+
return class UpgradableConstructor extends HTMLElement {
|
|
7513
|
+
constructor(upgradeCallback) {
|
|
7514
|
+
super();
|
|
7515
|
+
// If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
|
|
7516
|
+
// then elementBeingUpgraded will be false
|
|
7517
|
+
if (elementBeingUpgradedByLWC) {
|
|
7518
|
+
upgradeCallback(this);
|
|
7519
|
+
}
|
|
7520
|
+
else {
|
|
7521
|
+
// keep track of elements that were not created by lwc.createElement,
|
|
7522
|
+
// so we can ignore their lifecycle hooks
|
|
7523
|
+
elementsUpgradedOutsideLWC.add(this);
|
|
7524
|
+
// TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
|
7525
|
+
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
connectedCallback() {
|
|
7529
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
7530
|
+
connectedCallback(this);
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7533
|
+
disconnectedCallback() {
|
|
7534
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
7535
|
+
disconnectedCallback(this);
|
|
7536
|
+
}
|
|
7537
|
+
}
|
|
7538
|
+
};
|
|
7539
|
+
};
|
|
7540
|
+
const createCustomElementVanilla = (tagName, upgradeCallback, connectedCallback, disconnectedCallback) => {
|
|
7541
|
+
// use global custom elements registry
|
|
7542
|
+
let UpgradableConstructor = cachedConstructors.get(tagName);
|
|
7543
|
+
if (isUndefined$1(UpgradableConstructor)) {
|
|
7544
|
+
if (!isUndefined$1(customElements.get(tagName))) {
|
|
7545
|
+
throw new Error(`Unexpected tag name "${tagName}". This name is a registered custom element, preventing LWC to upgrade the element.`);
|
|
7546
|
+
}
|
|
7547
|
+
UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
|
|
7548
|
+
customElements.define(tagName, UpgradableConstructor);
|
|
7549
|
+
cachedConstructors.set(tagName, UpgradableConstructor);
|
|
7550
|
+
}
|
|
7551
|
+
elementBeingUpgradedByLWC = true;
|
|
7552
|
+
try {
|
|
7553
|
+
return new UpgradableConstructor(upgradeCallback);
|
|
7554
|
+
}
|
|
7555
|
+
finally {
|
|
7556
|
+
elementBeingUpgradedByLWC = false;
|
|
7557
|
+
}
|
|
7558
|
+
};
|
|
7559
|
+
|
|
7560
|
+
/*
|
|
7561
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
7562
|
+
* All rights reserved.
|
|
7563
|
+
* SPDX-License-Identifier: MIT
|
|
7564
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7565
|
+
*/
|
|
7566
|
+
/**
|
|
7567
|
+
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
7568
|
+
* do not conflict with vanilla custom elements having the same tag name.
|
|
7569
|
+
*/
|
|
7570
|
+
function createScopedRegistry() {
|
|
7571
|
+
if (!hasCustomElements) {
|
|
7572
|
+
// This code should never be reached, because we don't use the pivot registry if
|
|
7573
|
+
// custom elements are unavailable.
|
|
7574
|
+
throw new Error('Custom elements are not supported in this environment.');
|
|
7575
|
+
}
|
|
7576
|
+
const { HTMLElement: NativeHTMLElement } = window;
|
|
7577
|
+
const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
|
|
7578
|
+
const definitionForElement = new WeakMap();
|
|
7579
|
+
const pendingRegistryForElement = new WeakMap();
|
|
7580
|
+
const definitionForConstructor = new WeakMap();
|
|
7581
|
+
const registeredUserCtors = new WeakSet();
|
|
7582
|
+
const pivotCtorByTag = new Map();
|
|
7583
|
+
const globalDefinitionsByTag = new Map();
|
|
7584
|
+
const globalDefinitionsByClass = new Map();
|
|
7585
|
+
const awaitingUpgrade = new Map();
|
|
7586
|
+
const EMPTY_SET = new Set();
|
|
7587
|
+
function createDefinitionRecord(constructor) {
|
|
7588
|
+
var _a;
|
|
7589
|
+
const { connectedCallback, disconnectedCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
|
|
7590
|
+
const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
7591
|
+
return {
|
|
7592
|
+
UserCtor: constructor,
|
|
7593
|
+
PivotCtor: undefined,
|
|
7594
|
+
connectedCallback,
|
|
7595
|
+
disconnectedCallback,
|
|
7596
|
+
adoptedCallback,
|
|
7597
|
+
attributeChangedCallback,
|
|
7598
|
+
observedAttributes,
|
|
7599
|
+
};
|
|
7600
|
+
}
|
|
7601
|
+
// Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
7602
|
+
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
7603
|
+
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
7604
|
+
// constructor is invoked with another constructor.
|
|
7605
|
+
function createPivotingClass(tagName, registeredDefinition) {
|
|
7606
|
+
class PivotCtor extends NativeHTMLElement {
|
|
7607
|
+
constructor(UserCtor) {
|
|
7608
|
+
// This constructor can only be invoked by:
|
|
7609
|
+
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
7610
|
+
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
7611
|
+
// b) new UserClass.
|
|
7612
|
+
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
7613
|
+
// If the caller signals via UserCtor that this is in fact a controlled
|
|
7614
|
+
// definition, we use that one, otherwise fallback to the global
|
|
7615
|
+
// internal registry.
|
|
7616
|
+
super();
|
|
7617
|
+
const userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
7618
|
+
if (userCtorIsDefined) {
|
|
7619
|
+
if (!isConstructor(UserCtor)) {
|
|
7620
|
+
throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
|
|
7621
|
+
}
|
|
7622
|
+
if (!registeredUserCtors.has(UserCtor)) {
|
|
7623
|
+
throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
|
|
7624
|
+
}
|
|
7625
|
+
}
|
|
7626
|
+
const definition = userCtorIsDefined
|
|
7627
|
+
? getOrCreateDefinitionForConstructor(UserCtor)
|
|
7628
|
+
: globalDefinitionsByTag.get(tagName);
|
|
7629
|
+
if (!isUndefined$1(definition)) {
|
|
7630
|
+
internalUpgrade(this, registeredDefinition, definition);
|
|
7631
|
+
}
|
|
7632
|
+
else {
|
|
7633
|
+
// This is the case in which there is no global definition, and
|
|
7634
|
+
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
7635
|
+
// so we need to add it to the pending queue just in case it eventually
|
|
7636
|
+
// gets defined in the global registry.
|
|
7637
|
+
pendingRegistryForElement.set(this, registeredDefinition);
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
connectedCallback() {
|
|
7641
|
+
var _a;
|
|
7642
|
+
const definition = definitionForElement.get(this);
|
|
7643
|
+
if (!isUndefined$1(definition)) {
|
|
7644
|
+
// Delegate out to user callback
|
|
7645
|
+
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7646
|
+
}
|
|
7647
|
+
else {
|
|
7648
|
+
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
7649
|
+
let awaiting = awaitingUpgrade.get(tagName);
|
|
7650
|
+
if (isUndefined$1(awaiting)) {
|
|
7651
|
+
awaitingUpgrade.set(tagName, (awaiting = new Set()));
|
|
7652
|
+
}
|
|
7653
|
+
awaiting.add(this);
|
|
7654
|
+
}
|
|
7655
|
+
}
|
|
7656
|
+
disconnectedCallback() {
|
|
7657
|
+
var _a;
|
|
7658
|
+
const definition = definitionForElement.get(this);
|
|
7659
|
+
if (!isUndefined$1(definition)) {
|
|
7660
|
+
// Delegate out to user callback
|
|
7661
|
+
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7662
|
+
}
|
|
7663
|
+
else {
|
|
7664
|
+
// Un-register for upgrade when defined (so we don't leak)
|
|
7665
|
+
const awaiting = awaitingUpgrade.get(tagName);
|
|
7666
|
+
// At this point, awaiting should never be undefined, because connectedCallback
|
|
7667
|
+
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
7668
|
+
if (!isUndefined$1(awaiting)) {
|
|
7669
|
+
awaiting.delete(this);
|
|
7670
|
+
}
|
|
7671
|
+
}
|
|
7672
|
+
}
|
|
7673
|
+
adoptedCallback() {
|
|
7674
|
+
var _a;
|
|
7675
|
+
const definition = definitionForElement.get(this);
|
|
7676
|
+
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7677
|
+
}
|
|
7678
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
7679
|
+
var _a;
|
|
7680
|
+
const definition = definitionForElement.get(this);
|
|
7681
|
+
// if both definitions are the same, then the observedAttributes is the same,
|
|
7682
|
+
// but if they are different, only if the runtime definition has the attribute
|
|
7683
|
+
// marked as observed, then it should invoke attributeChangedCallback.
|
|
7684
|
+
if (registeredDefinition === definition ||
|
|
7685
|
+
(definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
7686
|
+
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
7687
|
+
}
|
|
7688
|
+
}
|
|
7689
|
+
}
|
|
7690
|
+
PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
|
|
7691
|
+
return PivotCtor;
|
|
7692
|
+
}
|
|
7693
|
+
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
7694
|
+
const { observedAttributes, attributeChangedCallback } = pivotDefinition;
|
|
7695
|
+
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
7696
|
+
// This instance does not need to observe any attributes, no need to patch
|
|
7697
|
+
return EMPTY_SET;
|
|
7698
|
+
}
|
|
7699
|
+
// Natively, the attributes observed by the registered definition are going to be taken
|
|
7700
|
+
// care of by the browser, only the difference between the two sets has to be taken
|
|
7701
|
+
// care by the patched version.
|
|
7702
|
+
return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
|
|
7703
|
+
}
|
|
7704
|
+
function throwAsyncError(error) {
|
|
7705
|
+
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
7706
|
+
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
7707
|
+
// to make it an unhandled error rather than an unhandled rejection.
|
|
7708
|
+
setTimeout(() => {
|
|
7709
|
+
throw error;
|
|
7710
|
+
});
|
|
7711
|
+
}
|
|
7712
|
+
// Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
7713
|
+
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
7714
|
+
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
7715
|
+
// and the second class observes attributes that aren't observed by the first one,
|
|
7716
|
+
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
7717
|
+
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
7718
|
+
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
7719
|
+
// that we aren't observing the attributes we need to.
|
|
7720
|
+
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
7721
|
+
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7722
|
+
if (newObservedAttributes.size === 0) {
|
|
7723
|
+
return;
|
|
7724
|
+
}
|
|
7725
|
+
const { attributeChangedCallback } = pivotDefinition;
|
|
7726
|
+
// Patch the instance.
|
|
7727
|
+
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
7728
|
+
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
7729
|
+
// `setAttribute` and `removeAttribute`.
|
|
7730
|
+
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
7731
|
+
defineProperties(instance, {
|
|
7732
|
+
setAttribute: {
|
|
7733
|
+
value: function setAttribute(name, value) {
|
|
7734
|
+
if (newObservedAttributes.has(name)) {
|
|
7735
|
+
const old = nativeGetAttribute.call(this, name);
|
|
7736
|
+
nativeSetAttribute.call(this, name, value);
|
|
7737
|
+
try {
|
|
7738
|
+
attributeChangedCallback.call(this, name, old, value + '');
|
|
7739
|
+
}
|
|
7740
|
+
catch (error) {
|
|
7741
|
+
throwAsyncError(error);
|
|
7742
|
+
}
|
|
7743
|
+
}
|
|
7744
|
+
else {
|
|
7745
|
+
nativeSetAttribute.call(this, name, value);
|
|
7746
|
+
}
|
|
7747
|
+
},
|
|
7748
|
+
writable: true,
|
|
7749
|
+
enumerable: true,
|
|
7750
|
+
configurable: true,
|
|
7751
|
+
},
|
|
7752
|
+
removeAttribute: {
|
|
7753
|
+
value: function removeAttribute(name) {
|
|
7754
|
+
if (newObservedAttributes.has(name)) {
|
|
7755
|
+
const old = nativeGetAttribute.call(this, name);
|
|
7756
|
+
nativeRemoveAttribute.call(this, name);
|
|
7757
|
+
try {
|
|
7758
|
+
attributeChangedCallback.call(this, name, old, null);
|
|
7759
|
+
}
|
|
7760
|
+
catch (error) {
|
|
7761
|
+
throwAsyncError(error);
|
|
7762
|
+
}
|
|
7763
|
+
}
|
|
7764
|
+
else {
|
|
7765
|
+
nativeRemoveAttribute.call(this, name);
|
|
7766
|
+
}
|
|
7767
|
+
},
|
|
7768
|
+
writable: true,
|
|
7769
|
+
enumerable: true,
|
|
7770
|
+
configurable: true,
|
|
7771
|
+
},
|
|
7772
|
+
});
|
|
7773
|
+
}
|
|
7774
|
+
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7775
|
+
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
7776
|
+
// from a pre-existing one in the DOM.
|
|
7777
|
+
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7778
|
+
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
7779
|
+
return;
|
|
7780
|
+
}
|
|
7781
|
+
const { attributeChangedCallback } = pivotDefinition;
|
|
7782
|
+
// Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
7783
|
+
newObservedAttributes.forEach((name) => {
|
|
7784
|
+
if (nativeHasAttribute.call(instance, name)) {
|
|
7785
|
+
const newValue = nativeGetAttribute.call(instance, name);
|
|
7786
|
+
attributeChangedCallback.call(instance, name, null, newValue);
|
|
7787
|
+
}
|
|
7788
|
+
});
|
|
7789
|
+
}
|
|
7790
|
+
// User extends this HTMLElement, which returns the CE being upgraded
|
|
7791
|
+
let upgradingInstance;
|
|
7792
|
+
// Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
7793
|
+
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7794
|
+
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
7795
|
+
definitionForElement.set(instance, pivotDefinition);
|
|
7796
|
+
// attributes patches when needed
|
|
7797
|
+
if (pivotDefinition !== registeredDefinition) {
|
|
7798
|
+
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
7799
|
+
}
|
|
7800
|
+
// Tricking the construction path to believe that a new instance is being created,
|
|
7801
|
+
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
7802
|
+
// constructor will reuse the instance by returning the upgradingInstance.
|
|
7803
|
+
// This is by far the most important piece of the puzzle
|
|
7804
|
+
upgradingInstance = instance;
|
|
7805
|
+
// By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
7806
|
+
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
7807
|
+
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
7808
|
+
new pivotDefinition.UserCtor();
|
|
7809
|
+
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
7810
|
+
}
|
|
7811
|
+
function isConstructor(constructor) {
|
|
7812
|
+
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
7813
|
+
}
|
|
7814
|
+
function getOrCreateDefinitionForConstructor(constructor) {
|
|
7815
|
+
if (!isConstructor(constructor)) {
|
|
7816
|
+
throw new TypeError('The referenced constructor is not a constructor.');
|
|
7817
|
+
}
|
|
7818
|
+
const definition = definitionForConstructor.get(constructor);
|
|
7819
|
+
if (!isUndefined$1(definition)) {
|
|
7820
|
+
return definition;
|
|
7821
|
+
}
|
|
7822
|
+
return createDefinitionRecord(constructor);
|
|
7823
|
+
}
|
|
7824
|
+
const { customElements: nativeRegistry } = window;
|
|
7825
|
+
const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
|
|
7826
|
+
// patch for the global registry define mechanism
|
|
7827
|
+
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
7828
|
+
if (options && options.extends) {
|
|
7829
|
+
// TODO [#2983]: should we support `extends`?
|
|
7830
|
+
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
7831
|
+
}
|
|
7832
|
+
if (globalDefinitionsByTag.has(tagName)) {
|
|
7833
|
+
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
|
|
7834
|
+
}
|
|
7835
|
+
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
7836
|
+
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
|
|
7837
|
+
}
|
|
7838
|
+
const definition = getOrCreateDefinitionForConstructor(constructor);
|
|
7839
|
+
registeredUserCtors.add(constructor);
|
|
7840
|
+
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
7841
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7842
|
+
PivotCtor = createPivotingClass(tagName, definition);
|
|
7843
|
+
// Register a pivoting class which will handle global registry initializations
|
|
7844
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7845
|
+
}
|
|
7846
|
+
// Only cache after nativeDefine has been called, because if it throws an error
|
|
7847
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7848
|
+
definitionForConstructor.set(constructor, definition);
|
|
7849
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7850
|
+
globalDefinitionsByTag.set(tagName, definition);
|
|
7851
|
+
globalDefinitionsByClass.set(constructor, definition);
|
|
7852
|
+
// For globally defined custom elements, the definition associated
|
|
7853
|
+
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
7854
|
+
// new the UserCtor, so we know how to create the underlying element.
|
|
7855
|
+
definition.PivotCtor = PivotCtor;
|
|
7856
|
+
// Upgrade any elements created in this scope before customElements.define
|
|
7857
|
+
// was called, which should be exhibited by the following steps:
|
|
7858
|
+
// 1) LWC registers a tagName for an LWC component.
|
|
7859
|
+
// 2) Element with same tagName is created with document.createElement()
|
|
7860
|
+
// and inserted into DOM.
|
|
7861
|
+
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
7862
|
+
// This requires immediate upgrade when the new global tagName is defined.
|
|
7863
|
+
const awaiting = awaitingUpgrade.get(tagName);
|
|
7864
|
+
if (!isUndefined$1(awaiting)) {
|
|
7865
|
+
awaitingUpgrade.delete(tagName);
|
|
7866
|
+
for (const element of awaiting) {
|
|
7867
|
+
const registeredDefinition = pendingRegistryForElement.get(element);
|
|
7868
|
+
// At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
7869
|
+
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
7870
|
+
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
7871
|
+
// But just to be safe, we check.
|
|
7872
|
+
if (!isUndefined$1(registeredDefinition)) {
|
|
7873
|
+
pendingRegistryForElement.delete(element);
|
|
7874
|
+
internalUpgrade(element, registeredDefinition, definition);
|
|
7875
|
+
}
|
|
7876
|
+
}
|
|
7877
|
+
}
|
|
7878
|
+
};
|
|
7879
|
+
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
7880
|
+
const NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
7881
|
+
if (!isUndefined$1(NativeCtor)) {
|
|
7882
|
+
const definition = globalDefinitionsByTag.get(tagName);
|
|
7883
|
+
if (!isUndefined$1(definition)) {
|
|
7884
|
+
return definition.UserCtor; // defined by the patched custom elements registry
|
|
7885
|
+
}
|
|
7886
|
+
// TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7887
|
+
return NativeCtor; // return the pivot constructor or constructor that existed before patching
|
|
7888
|
+
}
|
|
7889
|
+
};
|
|
7890
|
+
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
7891
|
+
return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
|
|
7892
|
+
const definition = globalDefinitionsByTag.get(tagName);
|
|
7893
|
+
if (!isUndefined$1(definition)) {
|
|
7894
|
+
return definition.UserCtor;
|
|
7895
|
+
}
|
|
7896
|
+
// TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7897
|
+
// In this case, the custom element must have been defined before the registry patches
|
|
7898
|
+
// were applied. So return the non-pivot constructor
|
|
7899
|
+
if (isUndefined$1(NativeCtor)) {
|
|
7900
|
+
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
7901
|
+
// We can patch the correct behavior using customElements.get()
|
|
7902
|
+
return nativeGet.call(nativeRegistry, tagName);
|
|
7903
|
+
}
|
|
7904
|
+
return NativeCtor;
|
|
7905
|
+
});
|
|
7906
|
+
};
|
|
7907
|
+
// This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
7908
|
+
// @ts-ignore
|
|
7909
|
+
window.HTMLElement = function HTMLElement() {
|
|
7910
|
+
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
7911
|
+
// native custom elements and we're in the process of running the
|
|
7912
|
+
// "constructor-call trick" on the natively constructed instance, so just
|
|
7913
|
+
// return that here.
|
|
7914
|
+
// This code path is also called when LWC `new`s a PivotCtor.
|
|
7915
|
+
const instance = upgradingInstance;
|
|
7916
|
+
if (!isUndefined$1(instance)) {
|
|
7917
|
+
upgradingInstance = undefined;
|
|
7918
|
+
return instance;
|
|
7919
|
+
}
|
|
7920
|
+
// Construction case: we need to construct the pivoting instance and return it.
|
|
7921
|
+
// This is possible when the user register it via global registry and instantiate
|
|
7922
|
+
// it via `new Ctor()`.
|
|
7923
|
+
const { constructor } = this;
|
|
7924
|
+
const definition = globalDefinitionsByClass.get(constructor);
|
|
7925
|
+
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
7926
|
+
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
7927
|
+
// doing `customElements.define()` first. This matches native browser behavior:
|
|
7928
|
+
// https://stackoverflow.com/a/61883392
|
|
7929
|
+
throw new TypeError('Illegal constructor');
|
|
7930
|
+
}
|
|
7931
|
+
// This constructor is ONLY invoked when it is the user instantiating
|
|
7932
|
+
// an element via new Ctor while Ctor is a registered global constructor.
|
|
7933
|
+
const { PivotCtor, UserCtor } = definition;
|
|
7934
|
+
return new PivotCtor(UserCtor);
|
|
7935
|
+
};
|
|
7936
|
+
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
7937
|
+
/**
|
|
7938
|
+
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
7939
|
+
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
7940
|
+
* is a hint that can be used when registering a custom element with the global custom elements
|
|
7941
|
+
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
7942
|
+
* as "safe" to be used when passed in to a PivotConstructor.
|
|
7943
|
+
*
|
|
7944
|
+
* @param tagName - element tag name
|
|
7945
|
+
* @param UserCtor - userland custom element constructor
|
|
7946
|
+
* @returns a new custom element constructor
|
|
7947
|
+
*/
|
|
7948
|
+
return function createPivotConstructor(tagName, UserCtor) {
|
|
7949
|
+
tagName = StringToLowerCase.call(tagName);
|
|
7950
|
+
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
7951
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7952
|
+
const definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
7953
|
+
PivotCtor = createPivotingClass(tagName, definition);
|
|
7954
|
+
// Register a pivoting class as a global custom element
|
|
7955
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7956
|
+
definition.PivotCtor = PivotCtor;
|
|
7957
|
+
// Only cache after nativeDefine has been called, because if it throws an error
|
|
7958
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7959
|
+
definitionForConstructor.set(UserCtor, definition);
|
|
7960
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7961
|
+
}
|
|
7962
|
+
// Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
7963
|
+
registeredUserCtors.add(UserCtor);
|
|
7964
|
+
return PivotCtor;
|
|
7965
|
+
};
|
|
7966
|
+
}
|
|
7967
|
+
|
|
7968
|
+
/*
|
|
7969
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7970
|
+
* All rights reserved.
|
|
7971
|
+
* SPDX-License-Identifier: MIT
|
|
7972
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7973
|
+
*/
|
|
7974
|
+
let createScopedConstructor;
|
|
7975
|
+
let CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
7976
|
+
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
7977
|
+
// or we're in a legacy browser.
|
|
7978
|
+
|
|
7979
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
7980
|
+
if (hasCustomElements) {
|
|
7981
|
+
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
7982
|
+
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
7983
|
+
//
|
|
7984
|
+
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
7985
|
+
//
|
|
7986
|
+
// 1. LWC loads
|
|
7987
|
+
// 2. `const Ctor = class extends HTMLElement {}`
|
|
7988
|
+
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
7989
|
+
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
7990
|
+
//
|
|
7991
|
+
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
7992
|
+
createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
7993
|
+
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
7994
|
+
// because the HTMLElement prototypes are mixed up.
|
|
7995
|
+
//
|
|
7996
|
+
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
7997
|
+
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
7998
|
+
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
7999
|
+
// Caching avoids this problem.
|
|
8000
|
+
|
|
8001
|
+
CachedHTMLElement = window.HTMLElement;
|
|
8002
|
+
}
|
|
8003
|
+
} // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
8004
|
+
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
8005
|
+
// multiple times per tag name.
|
|
8006
|
+
|
|
8007
|
+
|
|
8008
|
+
const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
|
|
8009
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
8010
|
+
return class UserConstructor extends HTMLElementToExtend {
|
|
8011
|
+
constructor() {
|
|
8012
|
+
super();
|
|
8013
|
+
upgradeCallback(this);
|
|
8014
|
+
}
|
|
8015
|
+
|
|
8016
|
+
connectedCallback() {
|
|
8017
|
+
connectedCallback(this);
|
|
8018
|
+
}
|
|
8019
|
+
|
|
8020
|
+
disconnectedCallback() {
|
|
8021
|
+
disconnectedCallback(this);
|
|
8022
|
+
}
|
|
8023
|
+
|
|
8024
|
+
};
|
|
8025
|
+
};
|
|
8026
|
+
|
|
8027
|
+
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
8028
|
+
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
8029
|
+
// This error should be impossible to hit
|
|
8030
|
+
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
8031
|
+
}
|
|
8032
|
+
|
|
8033
|
+
const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
8034
|
+
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
8035
|
+
return new ScopedConstructor(UserConstructor);
|
|
8036
|
+
}
|
|
8037
|
+
|
|
8038
|
+
/*
|
|
8039
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8040
|
+
* All rights reserved.
|
|
8041
|
+
* SPDX-License-Identifier: MIT
|
|
8042
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8043
|
+
*/
|
|
8044
|
+
/**
|
|
8045
|
+
* We have three modes for creating custom elements:
|
|
8046
|
+
*
|
|
8047
|
+
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
8048
|
+
* 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
|
|
8049
|
+
* same tag name, via a simple trick: every custom element constructor we define in the registry is basically
|
|
8050
|
+
* the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
|
|
8051
|
+
* constructor, which allows us to have completely customized functionality for different components.
|
|
8052
|
+
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
8053
|
+
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
8054
|
+
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
8055
|
+
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
8056
|
+
*/
|
|
8057
|
+
|
|
8058
|
+
let createCustomElement;
|
|
8059
|
+
|
|
8060
|
+
if (hasCustomElements) {
|
|
8061
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8062
|
+
createCustomElement = createCustomElementScoped;
|
|
8063
|
+
} else {
|
|
8064
|
+
// use global custom elements registry (vanilla)
|
|
8065
|
+
createCustomElement = createCustomElementVanilla;
|
|
8066
|
+
}
|
|
8067
|
+
} else {
|
|
8068
|
+
// no registry available here
|
|
8069
|
+
createCustomElement = createCustomElementCompat;
|
|
8070
|
+
}
|
|
8071
|
+
|
|
7510
8072
|
/*
|
|
7511
8073
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7512
8074
|
* All rights reserved.
|
|
@@ -7567,7 +8129,7 @@
|
|
|
7567
8129
|
function isNull(obj) {
|
|
7568
8130
|
return obj === null;
|
|
7569
8131
|
}
|
|
7570
|
-
/** version: 2.
|
|
8132
|
+
/** version: 2.27.0 */
|
|
7571
8133
|
|
|
7572
8134
|
/*
|
|
7573
8135
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7575,65 +8137,6 @@
|
|
|
7575
8137
|
* SPDX-License-Identifier: MIT
|
|
7576
8138
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7577
8139
|
*/
|
|
7578
|
-
exports.getCustomElement = void 0;
|
|
7579
|
-
exports.defineCustomElement = void 0;
|
|
7580
|
-
let HTMLElementConstructor;
|
|
7581
|
-
function isCustomElementRegistryAvailable() {
|
|
7582
|
-
if (typeof customElements === 'undefined') {
|
|
7583
|
-
return false;
|
|
7584
|
-
}
|
|
7585
|
-
try {
|
|
7586
|
-
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
7587
|
-
// _wrapNativeSuper()
|
|
7588
|
-
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
7589
|
-
// get wrapped by babel.
|
|
7590
|
-
const HTMLElementAlias = HTMLElement;
|
|
7591
|
-
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7592
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7593
|
-
// which are not equipped to be initialized that way.
|
|
7594
|
-
class clazz extends HTMLElementAlias {
|
|
7595
|
-
}
|
|
7596
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7597
|
-
new clazz();
|
|
7598
|
-
return true;
|
|
7599
|
-
}
|
|
7600
|
-
catch (_a) {
|
|
7601
|
-
return false;
|
|
7602
|
-
}
|
|
7603
|
-
}
|
|
7604
|
-
if (isCustomElementRegistryAvailable()) {
|
|
7605
|
-
exports.getCustomElement = customElements.get.bind(customElements);
|
|
7606
|
-
exports.defineCustomElement = customElements.define.bind(customElements);
|
|
7607
|
-
HTMLElementConstructor = HTMLElement;
|
|
7608
|
-
}
|
|
7609
|
-
else {
|
|
7610
|
-
const registry = Object.create(null);
|
|
7611
|
-
const reverseRegistry = new WeakMap();
|
|
7612
|
-
exports.defineCustomElement = function define(name, ctor) {
|
|
7613
|
-
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
7614
|
-
throw new TypeError(`Invalid Registration`);
|
|
7615
|
-
}
|
|
7616
|
-
registry[name] = ctor;
|
|
7617
|
-
reverseRegistry.set(ctor, name);
|
|
7618
|
-
};
|
|
7619
|
-
exports.getCustomElement = function get(name) {
|
|
7620
|
-
return registry[name];
|
|
7621
|
-
};
|
|
7622
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
7623
|
-
if (!(this instanceof HTMLElement)) {
|
|
7624
|
-
throw new TypeError(`Invalid Invocation`);
|
|
7625
|
-
}
|
|
7626
|
-
const { constructor } = this;
|
|
7627
|
-
const name = reverseRegistry.get(constructor);
|
|
7628
|
-
if (!name) {
|
|
7629
|
-
throw new TypeError(`Invalid Construction`);
|
|
7630
|
-
}
|
|
7631
|
-
const elm = document.createElement(name);
|
|
7632
|
-
Object.setPrototypeOf(elm, constructor.prototype);
|
|
7633
|
-
return elm;
|
|
7634
|
-
};
|
|
7635
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7636
|
-
}
|
|
7637
8140
|
function cloneNode(node, deep) {
|
|
7638
8141
|
return node.cloneNode(deep);
|
|
7639
8142
|
}
|
|
@@ -7807,9 +8310,7 @@
|
|
|
7807
8310
|
function assertInstanceOfHTMLElement(elm, msg) {
|
|
7808
8311
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7809
8312
|
}
|
|
7810
|
-
const HTMLElementExported = HTMLElementConstructor;
|
|
7811
8313
|
|
|
7812
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
7813
8314
|
exports.addEventListener = addEventListener;
|
|
7814
8315
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
7815
8316
|
exports.attachShadow = attachShadow;
|
|
@@ -7869,6 +8370,8 @@
|
|
|
7869
8370
|
{
|
|
7870
8371
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7871
8372
|
insertStylesheet,
|
|
8373
|
+
// relies on a shared global cache
|
|
8374
|
+
createCustomElement,
|
|
7872
8375
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7873
8376
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7874
8377
|
});
|
|
@@ -7969,36 +8472,44 @@
|
|
|
7969
8472
|
// This WeakSet usage is valid because this functionality is not meant to run in IE11.
|
|
7970
8473
|
const hydratedCustomElements = new WeakSet();
|
|
7971
8474
|
function buildCustomElementConstructor(Ctor) {
|
|
8475
|
+
var _a;
|
|
7972
8476
|
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
8477
|
+
const { observedAttributes } = HtmlPrototype;
|
|
8478
|
+
const { attributeChangedCallback } = HtmlPrototype.prototype;
|
|
8479
|
+
return _a = class extends HTMLElement {
|
|
8480
|
+
constructor() {
|
|
8481
|
+
super();
|
|
8482
|
+
if (this.isConnected) {
|
|
8483
|
+
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
8484
|
+
hydrateComponent(this, Ctor, {});
|
|
8485
|
+
hydratedCustomElements.add(this);
|
|
8486
|
+
}
|
|
8487
|
+
else {
|
|
8488
|
+
createVM(this, Ctor, renderer, {
|
|
8489
|
+
mode: 'open',
|
|
8490
|
+
owner: null,
|
|
8491
|
+
tagName: this.tagName,
|
|
8492
|
+
});
|
|
8493
|
+
}
|
|
7980
8494
|
}
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
8495
|
+
connectedCallback() {
|
|
8496
|
+
if (hydratedCustomElements.has(this)) {
|
|
8497
|
+
// This is an un-upgraded element that was hydrated in the constructor.
|
|
8498
|
+
hydratedCustomElements.delete(this);
|
|
8499
|
+
}
|
|
8500
|
+
else {
|
|
8501
|
+
connectRootElement(this);
|
|
8502
|
+
}
|
|
7987
8503
|
}
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
if (hydratedCustomElements.has(this)) {
|
|
7991
|
-
// This is an un-upgraded element that was hydrated in the constructor.
|
|
7992
|
-
hydratedCustomElements.delete(this);
|
|
8504
|
+
disconnectedCallback() {
|
|
8505
|
+
disconnectRootElement(this);
|
|
7993
8506
|
}
|
|
7994
|
-
|
|
7995
|
-
|
|
8507
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
8508
|
+
attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
7996
8509
|
}
|
|
7997
|
-
}
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
}
|
|
8001
|
-
};
|
|
8510
|
+
},
|
|
8511
|
+
_a.observedAttributes = observedAttributes,
|
|
8512
|
+
_a;
|
|
8002
8513
|
}
|
|
8003
8514
|
|
|
8004
8515
|
/*
|
|
@@ -8085,8 +8596,13 @@
|
|
|
8085
8596
|
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
8086
8597
|
}
|
|
8087
8598
|
|
|
8088
|
-
const
|
|
8089
|
-
|
|
8599
|
+
const {
|
|
8600
|
+
createCustomElement
|
|
8601
|
+
} = renderer; // tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
8602
|
+
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
8603
|
+
// the following line guarantees that this does not leaks beyond this point.
|
|
8604
|
+
|
|
8605
|
+
const tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
|
|
8090
8606
|
|
|
8091
8607
|
/**
|
|
8092
8608
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -8095,9 +8611,9 @@
|
|
|
8095
8611
|
* an upgradable custom element.
|
|
8096
8612
|
*/
|
|
8097
8613
|
|
|
8098
|
-
const
|
|
8614
|
+
const upgradeCallback = elm => {
|
|
8099
8615
|
createVM(elm, Ctor, renderer, {
|
|
8100
|
-
tagName
|
|
8616
|
+
tagName,
|
|
8101
8617
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
8102
8618
|
owner: null
|
|
8103
8619
|
});
|
|
@@ -8106,15 +8622,21 @@
|
|
|
8106
8622
|
ConnectingSlot.set(elm, connectRootElement);
|
|
8107
8623
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
8108
8624
|
}
|
|
8625
|
+
};
|
|
8109
8626
|
|
|
8110
|
-
|
|
8111
|
-
|
|
8627
|
+
const connectedCallback = elm => {
|
|
8628
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8629
|
+
connectRootElement(elm);
|
|
8630
|
+
}
|
|
8631
|
+
};
|
|
8112
8632
|
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8633
|
+
const disconnectedCallback = elm => {
|
|
8634
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8635
|
+
disconnectRootElement(elm);
|
|
8636
|
+
}
|
|
8637
|
+
};
|
|
8117
8638
|
|
|
8639
|
+
const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
8118
8640
|
return element;
|
|
8119
8641
|
}
|
|
8120
8642
|
|
|
@@ -8186,7 +8708,7 @@
|
|
|
8186
8708
|
});
|
|
8187
8709
|
freeze(LightningElement);
|
|
8188
8710
|
seal(LightningElement.prototype);
|
|
8189
|
-
/* version: 2.
|
|
8711
|
+
/* version: 2.27.0 */
|
|
8190
8712
|
|
|
8191
8713
|
exports.LightningElement = LightningElement;
|
|
8192
8714
|
exports.__unstable__ProfilerControl = profilerControl;
|