lwc 2.25.0 → 2.26.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 +1103 -533
- package/dist/engine-dom/iife/es2017/engine-dom.js +1103 -533
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +942 -320
- package/dist/engine-dom/iife/es5/engine-dom.js +966 -312
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +895 -225
- package/dist/engine-dom/umd/es2017/engine-dom.js +1103 -533
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +942 -320
- package/dist/engine-dom/umd/es5/engine-dom.js +966 -312
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +895 -225
- package/dist/engine-server/commonjs/es2017/engine-server.js +331 -339
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +331 -339
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -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.26.0";
|
|
309
309
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
310
|
-
/** version: 2.
|
|
310
|
+
/** version: 2.26.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.26.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,
|
|
@@ -415,6 +414,8 @@
|
|
|
415
414
|
ENABLE_REACTIVE_SETTER: null,
|
|
416
415
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
417
416
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
417
|
+
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
418
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
418
419
|
};
|
|
419
420
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
420
421
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -468,7 +469,7 @@
|
|
|
468
469
|
setFeatureFlag(name, value);
|
|
469
470
|
}
|
|
470
471
|
}
|
|
471
|
-
/** version: 2.
|
|
472
|
+
/** version: 2.26.0 */
|
|
472
473
|
|
|
473
474
|
/*
|
|
474
475
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1942,7 +1943,9 @@
|
|
|
1942
1943
|
const LightningElement = function () {
|
|
1943
1944
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1944
1945
|
if (isNull(vmBeingConstructed)) {
|
|
1945
|
-
|
|
1946
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1947
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1948
|
+
throw new TypeError('Illegal constructor');
|
|
1946
1949
|
}
|
|
1947
1950
|
const vm = vmBeingConstructed;
|
|
1948
1951
|
const { def, elm } = vm;
|
|
@@ -2991,274 +2994,213 @@
|
|
|
2991
2994
|
const activeTemplates = new WeakMap();
|
|
2992
2995
|
const activeComponents = new WeakMap();
|
|
2993
2996
|
const activeStyles = new WeakMap();
|
|
2994
|
-
|
|
2995
2997
|
function rehydrateHotTemplate(tpl) {
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
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;
|
|
3013
3013
|
}
|
|
3014
|
-
|
|
3015
3014
|
function rehydrateHotStyle(style) {
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
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;
|
|
3031
3028
|
}
|
|
3032
|
-
|
|
3033
3029
|
function rehydrateHotComponent(Ctor) {
|
|
3034
|
-
|
|
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
|
-
list.clear();
|
|
3061
|
-
}
|
|
3062
|
-
|
|
3063
|
-
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;
|
|
3064
3056
|
}
|
|
3065
|
-
|
|
3066
3057
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3058
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3059
|
+
// this method should never leak to prod
|
|
3060
|
+
throw new ReferenceError();
|
|
3061
|
+
}
|
|
3073
3062
|
const visited = new Set();
|
|
3074
|
-
|
|
3075
3063
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
3076
|
-
|
|
3077
|
-
|
|
3064
|
+
visited.add(tpl);
|
|
3065
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
3078
3066
|
}
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
return tpl;
|
|
3067
|
+
return tpl;
|
|
3082
3068
|
}
|
|
3083
3069
|
function getComponentOrSwappedComponent(Ctor) {
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3070
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3071
|
+
// this method should never leak to prod
|
|
3072
|
+
throw new ReferenceError();
|
|
3073
|
+
}
|
|
3090
3074
|
const visited = new Set();
|
|
3091
|
-
|
|
3092
3075
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
3093
|
-
|
|
3094
|
-
|
|
3076
|
+
visited.add(Ctor);
|
|
3077
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
3095
3078
|
}
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
return Ctor;
|
|
3079
|
+
return Ctor;
|
|
3099
3080
|
}
|
|
3100
3081
|
function getStyleOrSwappedStyle(style) {
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3082
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3083
|
+
// this method should never leak to prod
|
|
3084
|
+
throw new ReferenceError();
|
|
3085
|
+
}
|
|
3107
3086
|
const visited = new Set();
|
|
3108
|
-
|
|
3109
3087
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
3110
|
-
|
|
3111
|
-
|
|
3088
|
+
visited.add(style);
|
|
3089
|
+
style = swappedStyleMap.get(style);
|
|
3112
3090
|
}
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
return style;
|
|
3091
|
+
return style;
|
|
3116
3092
|
}
|
|
3117
3093
|
function setActiveVM(vm) {
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3094
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3095
|
+
// this method should never leak to prod
|
|
3096
|
+
throw new ReferenceError();
|
|
3097
|
+
}
|
|
3124
3098
|
// tracking active component
|
|
3125
3099
|
const Ctor = vm.def.ctor;
|
|
3126
3100
|
let componentVMs = activeComponents.get(Ctor);
|
|
3127
|
-
|
|
3128
3101
|
if (isUndefined$1(componentVMs)) {
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
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
|
|
3136
3108
|
const tpl = vm.cmpTemplate;
|
|
3137
|
-
|
|
3138
3109
|
if (tpl) {
|
|
3139
|
-
|
|
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
|
-
stylesheetVMs.add(vm);
|
|
3169
|
-
});
|
|
3170
|
-
}
|
|
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
|
+
}
|
|
3171
3137
|
}
|
|
3172
|
-
}
|
|
3173
3138
|
}
|
|
3174
3139
|
function removeActiveVM(vm) {
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3140
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3141
|
+
// this method should never leak to prod
|
|
3142
|
+
throw new ReferenceError();
|
|
3143
|
+
}
|
|
3181
3144
|
// tracking inactive component
|
|
3182
3145
|
const Ctor = vm.def.ctor;
|
|
3183
3146
|
let list = activeComponents.get(Ctor);
|
|
3184
|
-
|
|
3185
3147
|
if (!isUndefined$1(list)) {
|
|
3186
|
-
// deleting the vm from the set to avoid leaking memory
|
|
3187
|
-
list.delete(vm);
|
|
3188
|
-
} // removing inactive template
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
const tpl = vm.cmpTemplate;
|
|
3192
|
-
|
|
3193
|
-
if (tpl) {
|
|
3194
|
-
list = activeTemplates.get(tpl);
|
|
3195
|
-
|
|
3196
|
-
if (!isUndefined$1(list)) {
|
|
3197
3148
|
// deleting the vm from the set to avoid leaking memory
|
|
3198
3149
|
list.delete(vm);
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
flattenStylesheets(styles).forEach(style => {
|
|
3206
|
-
list = activeStyles.get(style);
|
|
3207
|
-
|
|
3208
|
-
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)) {
|
|
3209
3156
|
// deleting the vm from the set to avoid leaking memory
|
|
3210
3157
|
list.delete(vm);
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
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
|
+
}
|
|
3214
3170
|
}
|
|
3215
|
-
}
|
|
3216
3171
|
}
|
|
3217
3172
|
function swapTemplate(oldTpl, newTpl) {
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
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
|
+
}
|
|
3224
3181
|
}
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3228
|
-
throw new Error('HMR is not enabled');
|
|
3229
|
-
}
|
|
3230
|
-
|
|
3231
|
-
return false;
|
|
3182
|
+
return false;
|
|
3232
3183
|
}
|
|
3233
3184
|
function swapComponent(oldComponent, newComponent) {
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
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
|
+
}
|
|
3240
3193
|
}
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3244
|
-
throw new Error('HMR is not enabled');
|
|
3245
|
-
}
|
|
3246
|
-
|
|
3247
|
-
return false;
|
|
3194
|
+
return false;
|
|
3248
3195
|
}
|
|
3249
3196
|
function swapStyle(oldStyle, newStyle) {
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3258
|
-
throw new Error('HMR is not enabled');
|
|
3259
|
-
}
|
|
3260
|
-
|
|
3261
|
-
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;
|
|
3262
3204
|
}
|
|
3263
3205
|
|
|
3264
3206
|
/*
|
|
@@ -3465,244 +3407,273 @@
|
|
|
3465
3407
|
* SPDX-License-Identifier: MIT
|
|
3466
3408
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3467
3409
|
*/
|
|
3410
|
+
|
|
3468
3411
|
function makeHostToken(token) {
|
|
3469
|
-
|
|
3412
|
+
return `${token}-host`;
|
|
3470
3413
|
}
|
|
3414
|
+
|
|
3471
3415
|
function createInlineStyleVNode(content) {
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3416
|
+
return api.h('style', {
|
|
3417
|
+
key: 'style',
|
|
3418
|
+
attrs: {
|
|
3419
|
+
type: 'text/css'
|
|
3420
|
+
}
|
|
3421
|
+
}, [api.t(content)]);
|
|
3478
3422
|
}
|
|
3423
|
+
|
|
3479
3424
|
function updateStylesheetToken(vm, template) {
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3425
|
+
const {
|
|
3426
|
+
elm,
|
|
3427
|
+
context,
|
|
3428
|
+
renderMode,
|
|
3429
|
+
shadowMode,
|
|
3430
|
+
renderer: {
|
|
3431
|
+
getClassList,
|
|
3432
|
+
removeAttribute,
|
|
3433
|
+
setAttribute
|
|
3434
|
+
}
|
|
3435
|
+
} = vm;
|
|
3436
|
+
const {
|
|
3437
|
+
stylesheets: newStylesheets,
|
|
3438
|
+
stylesheetToken: newStylesheetToken
|
|
3439
|
+
} = template;
|
|
3440
|
+
const isSyntheticShadow = renderMode === 1
|
|
3441
|
+
/* RenderMode.Shadow */
|
|
3442
|
+
&& shadowMode === 1
|
|
3443
|
+
/* ShadowMode.Synthetic */
|
|
3444
|
+
;
|
|
3445
|
+
const {
|
|
3446
|
+
hasScopedStyles
|
|
3447
|
+
} = context;
|
|
3448
|
+
let newToken;
|
|
3449
|
+
let newHasTokenInClass;
|
|
3450
|
+
let newHasTokenInAttribute; // Reset the styling token applied to the host element.
|
|
3451
|
+
|
|
3452
|
+
const {
|
|
3453
|
+
stylesheetToken: oldToken,
|
|
3454
|
+
hasTokenInClass: oldHasTokenInClass,
|
|
3455
|
+
hasTokenInAttribute: oldHasTokenInAttribute
|
|
3456
|
+
} = context;
|
|
3457
|
+
|
|
3458
|
+
if (!isUndefined$1(oldToken)) {
|
|
3459
|
+
if (oldHasTokenInClass) {
|
|
3460
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3461
|
+
}
|
|
3462
|
+
|
|
3463
|
+
if (oldHasTokenInAttribute) {
|
|
3464
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
3465
|
+
}
|
|
3466
|
+
} // Apply the new template styling token to the host element, if the new template has any
|
|
3467
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3468
|
+
|
|
3469
|
+
|
|
3470
|
+
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
3471
|
+
newToken = newStylesheetToken;
|
|
3472
|
+
} // Set the new styling token on the host element
|
|
3473
|
+
|
|
3474
|
+
|
|
3475
|
+
if (!isUndefined$1(newToken)) {
|
|
3476
|
+
if (hasScopedStyles) {
|
|
3477
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
3478
|
+
newHasTokenInClass = true;
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
if (isSyntheticShadow) {
|
|
3482
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
3483
|
+
newHasTokenInAttribute = true;
|
|
3484
|
+
}
|
|
3485
|
+
} // Update the styling tokens present on the context object.
|
|
3486
|
+
|
|
3487
|
+
|
|
3488
|
+
context.stylesheetToken = newToken;
|
|
3489
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
3490
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3517
3491
|
}
|
|
3492
|
+
|
|
3518
3493
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3494
|
+
const content = [];
|
|
3495
|
+
let root;
|
|
3496
|
+
|
|
3497
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3498
|
+
let stylesheet = stylesheets[i];
|
|
3499
|
+
|
|
3500
|
+
if (isArray$1(stylesheet)) {
|
|
3501
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3502
|
+
} else {
|
|
3503
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3504
|
+
// Check for compiler version mismatch in dev mode only
|
|
3505
|
+
checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3506
|
+
// the component instance might be attempting to use an old version of
|
|
3507
|
+
// the stylesheet, while internally, we have a replacement for it.
|
|
3508
|
+
|
|
3509
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3513
|
+
|
|
3514
|
+
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
|
|
3515
|
+
if (!isScopedCss && vm.renderMode === 0
|
|
3516
|
+
/* RenderMode.Light */
|
|
3517
|
+
) {
|
|
3518
|
+
logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
|
|
3519
|
+
continue;
|
|
3525
3520
|
}
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
root = getNearestShadowComponent(vm);
|
|
3558
|
-
}
|
|
3559
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3560
|
-
}
|
|
3561
|
-
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3521
|
+
} // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3522
|
+
|
|
3523
|
+
|
|
3524
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1
|
|
3525
|
+
/* ShadowMode.Synthetic */
|
|
3526
|
+
&& vm.renderMode === 1
|
|
3527
|
+
/* RenderMode.Shadow */
|
|
3528
|
+
? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3529
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3530
|
+
|
|
3531
|
+
const useActualHostSelector = vm.renderMode === 0
|
|
3532
|
+
/* RenderMode.Light */
|
|
3533
|
+
? !isScopedCss : vm.shadowMode === 0
|
|
3534
|
+
/* ShadowMode.Native */
|
|
3535
|
+
; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3536
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
3537
|
+
|
|
3538
|
+
let useNativeDirPseudoclass;
|
|
3539
|
+
|
|
3540
|
+
if (vm.renderMode === 1
|
|
3541
|
+
/* RenderMode.Shadow */
|
|
3542
|
+
) {
|
|
3543
|
+
useNativeDirPseudoclass = vm.shadowMode === 0
|
|
3544
|
+
/* ShadowMode.Native */
|
|
3545
|
+
;
|
|
3546
|
+
} else {
|
|
3547
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3548
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
3549
|
+
if (isUndefined$1(root)) {
|
|
3550
|
+
// Only calculate the root once as necessary
|
|
3551
|
+
root = getNearestShadowComponent(vm);
|
|
3562
3552
|
}
|
|
3553
|
+
|
|
3554
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
|
|
3555
|
+
/* ShadowMode.Native */
|
|
3556
|
+
;
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3563
3560
|
}
|
|
3564
|
-
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
return content;
|
|
3565
3564
|
}
|
|
3565
|
+
|
|
3566
3566
|
function getStylesheetsContent(vm, template) {
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3567
|
+
const {
|
|
3568
|
+
stylesheets,
|
|
3569
|
+
stylesheetToken
|
|
3570
|
+
} = template;
|
|
3571
|
+
let content = [];
|
|
3572
|
+
|
|
3573
|
+
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
3574
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
return content;
|
|
3578
|
+
} // It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3575
3579
|
// perf testing has not shown it to be a huge improvement yet:
|
|
3576
3580
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3581
|
+
|
|
3577
3582
|
function getNearestShadowComponent(vm) {
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3583
|
+
let owner = vm;
|
|
3584
|
+
|
|
3585
|
+
while (!isNull(owner)) {
|
|
3586
|
+
if (owner.renderMode === 1
|
|
3587
|
+
/* RenderMode.Shadow */
|
|
3588
|
+
) {
|
|
3589
|
+
return owner;
|
|
3584
3590
|
}
|
|
3585
|
-
|
|
3591
|
+
|
|
3592
|
+
owner = owner.owner;
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
return owner;
|
|
3586
3596
|
}
|
|
3587
3597
|
/**
|
|
3588
3598
|
* If the component that is currently being rendered uses scoped styles,
|
|
3589
3599
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3590
3600
|
* it returns null.
|
|
3591
3601
|
*/
|
|
3602
|
+
|
|
3603
|
+
|
|
3592
3604
|
function getScopeTokenClass(owner) {
|
|
3593
|
-
|
|
3594
|
-
|
|
3605
|
+
const {
|
|
3606
|
+
cmpTemplate,
|
|
3607
|
+
context
|
|
3608
|
+
} = owner;
|
|
3609
|
+
return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
|
|
3595
3610
|
}
|
|
3596
3611
|
/**
|
|
3597
3612
|
* This function returns the host style token for a custom element if it
|
|
3598
3613
|
* exists. Otherwise it returns null.
|
|
3614
|
+
*
|
|
3615
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3599
3616
|
*/
|
|
3617
|
+
|
|
3600
3618
|
function getStylesheetTokenHost(vnode) {
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
// synthetic, we know we won't find a native component if we go any further.
|
|
3609
|
-
return null;
|
|
3610
|
-
}
|
|
3611
|
-
return owner;
|
|
3612
|
-
}
|
|
3613
|
-
function createStylesheet(vm, stylesheets) {
|
|
3614
|
-
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3615
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3616
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3617
|
-
insertStylesheet(stylesheets[i]);
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
else if (vm.hydrated) {
|
|
3621
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3622
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3623
|
-
// the first time the VM renders.
|
|
3624
|
-
// native shadow or light DOM, SSR
|
|
3625
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3626
|
-
}
|
|
3627
|
-
else {
|
|
3628
|
-
// native shadow or light DOM, DOM renderer
|
|
3629
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
3630
|
-
// null root means a global style
|
|
3631
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3632
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3633
|
-
insertStylesheet(stylesheets[i], target);
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
return null;
|
|
3619
|
+
const {
|
|
3620
|
+
template
|
|
3621
|
+
} = getComponentInternalDef(vnode.ctor);
|
|
3622
|
+
const {
|
|
3623
|
+
stylesheetToken
|
|
3624
|
+
} = template;
|
|
3625
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3637
3626
|
}
|
|
3638
3627
|
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
* All rights reserved.
|
|
3642
|
-
* SPDX-License-Identifier: MIT
|
|
3643
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3644
|
-
*/
|
|
3645
|
-
|
|
3646
|
-
function checkHasVM(elm) {
|
|
3647
|
-
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3628
|
+
function getNearestNativeShadowComponent(vm) {
|
|
3629
|
+
const owner = getNearestShadowComponent(vm);
|
|
3648
3630
|
|
|
3649
|
-
if (
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3631
|
+
if (!isNull(owner) && owner.shadowMode === 1
|
|
3632
|
+
/* ShadowMode.Synthetic */
|
|
3633
|
+
) {
|
|
3634
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3635
|
+
// synthetic, we know we won't find a native component if we go any further.
|
|
3636
|
+
return null;
|
|
3653
3637
|
}
|
|
3654
3638
|
|
|
3655
|
-
return
|
|
3639
|
+
return owner;
|
|
3656
3640
|
}
|
|
3657
3641
|
|
|
3658
|
-
function
|
|
3642
|
+
function createStylesheet(vm, stylesheets) {
|
|
3659
3643
|
const {
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
// produce only tags with lowercase letters
|
|
3665
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
3666
|
-
|
|
3667
|
-
tagName = tagName.toLowerCase();
|
|
3668
|
-
let CE = getCustomElement(tagName);
|
|
3669
|
-
|
|
3670
|
-
if (!isUndefined$1(CE)) {
|
|
3671
|
-
return CE;
|
|
3672
|
-
}
|
|
3673
|
-
/**
|
|
3674
|
-
* LWC Upgradable Element reference to an element that was created
|
|
3675
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3676
|
-
*/
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3680
|
-
constructor(upgradeCallback) {
|
|
3681
|
-
super();
|
|
3682
|
-
|
|
3683
|
-
if (isFunction$1(upgradeCallback)) {
|
|
3684
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3685
|
-
}
|
|
3644
|
+
renderMode,
|
|
3645
|
+
shadowMode,
|
|
3646
|
+
renderer: {
|
|
3647
|
+
insertStylesheet
|
|
3686
3648
|
}
|
|
3649
|
+
} = vm;
|
|
3687
3650
|
|
|
3688
|
-
|
|
3651
|
+
if (renderMode === 1
|
|
3652
|
+
/* RenderMode.Shadow */
|
|
3653
|
+
&& shadowMode === 1
|
|
3654
|
+
/* ShadowMode.Synthetic */
|
|
3655
|
+
) {
|
|
3656
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3657
|
+
insertStylesheet(stylesheets[i]);
|
|
3658
|
+
}
|
|
3659
|
+
} else if (vm.hydrated) {
|
|
3660
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3661
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3662
|
+
// the first time the VM renders.
|
|
3663
|
+
// native shadow or light DOM, SSR
|
|
3664
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3665
|
+
} else {
|
|
3666
|
+
// native shadow or light DOM, DOM renderer
|
|
3667
|
+
const root = getNearestNativeShadowComponent(vm); // null root means a global style
|
|
3689
3668
|
|
|
3690
|
-
|
|
3691
|
-
CE.prototype.connectedCallback = function () {
|
|
3692
|
-
if (checkHasVM(this)) {
|
|
3693
|
-
connectRootElement(this);
|
|
3694
|
-
}
|
|
3695
|
-
};
|
|
3669
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3696
3670
|
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
}
|
|
3701
|
-
};
|
|
3671
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3672
|
+
insertStylesheet(stylesheets[i], target);
|
|
3673
|
+
}
|
|
3702
3674
|
}
|
|
3703
3675
|
|
|
3704
|
-
|
|
3705
|
-
return CE;
|
|
3676
|
+
return null;
|
|
3706
3677
|
}
|
|
3707
3678
|
|
|
3708
3679
|
/*
|
|
@@ -4218,7 +4189,9 @@
|
|
|
4218
4189
|
sel,
|
|
4219
4190
|
owner
|
|
4220
4191
|
} = vnode;
|
|
4221
|
-
const
|
|
4192
|
+
const {
|
|
4193
|
+
createCustomElement
|
|
4194
|
+
} = renderer;
|
|
4222
4195
|
/**
|
|
4223
4196
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4224
4197
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -4227,10 +4200,25 @@
|
|
|
4227
4200
|
*/
|
|
4228
4201
|
|
|
4229
4202
|
let vm;
|
|
4230
|
-
|
|
4203
|
+
|
|
4204
|
+
const upgradeCallback = elm => {
|
|
4231
4205
|
// the custom element from the registry is expecting an upgrade callback
|
|
4232
4206
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
4233
|
-
}
|
|
4207
|
+
};
|
|
4208
|
+
|
|
4209
|
+
const connectedCallback = elm => {
|
|
4210
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4211
|
+
connectRootElement(elm);
|
|
4212
|
+
}
|
|
4213
|
+
};
|
|
4214
|
+
|
|
4215
|
+
const disconnectedCallback = elm => {
|
|
4216
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4217
|
+
disconnectRootElement(elm);
|
|
4218
|
+
}
|
|
4219
|
+
};
|
|
4220
|
+
|
|
4221
|
+
const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
4234
4222
|
vnode.elm = elm;
|
|
4235
4223
|
vnode.vm = vm;
|
|
4236
4224
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -4238,8 +4226,6 @@
|
|
|
4238
4226
|
|
|
4239
4227
|
if (vm) {
|
|
4240
4228
|
allocateChildren(vnode, vm);
|
|
4241
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4242
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
4243
4229
|
}
|
|
4244
4230
|
|
|
4245
4231
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -7013,19 +6999,23 @@
|
|
|
7013
6999
|
//
|
|
7014
7000
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
7015
7001
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
7016
|
-
if (scopedToken) {
|
|
7002
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
7017
7003
|
if (!isUndefined$1(className)) {
|
|
7018
|
-
className
|
|
7019
|
-
|
|
7020
|
-
|
|
7004
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
7005
|
+
const classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
7006
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
7007
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
7021
7008
|
}
|
|
7022
7009
|
else if (!isUndefined$1(classMap)) {
|
|
7023
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {
|
|
7010
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
|
|
7024
7011
|
}
|
|
7025
7012
|
else {
|
|
7026
|
-
className
|
|
7027
|
-
|
|
7028
|
-
|
|
7013
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
7014
|
+
const classTokens = [scopedToken, stylesheetTokenHost];
|
|
7015
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
7016
|
+
if (classNames.length) {
|
|
7017
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
7018
|
+
}
|
|
7029
7019
|
}
|
|
7030
7020
|
}
|
|
7031
7021
|
let nodesAreCompatible = true;
|
|
@@ -7267,7 +7257,7 @@
|
|
|
7267
7257
|
}
|
|
7268
7258
|
return ctor;
|
|
7269
7259
|
}
|
|
7270
|
-
/* version: 2.
|
|
7260
|
+
/* version: 2.26.0 */
|
|
7271
7261
|
|
|
7272
7262
|
/*
|
|
7273
7263
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7411,6 +7401,626 @@
|
|
|
7411
7401
|
}
|
|
7412
7402
|
}
|
|
7413
7403
|
|
|
7404
|
+
/*
|
|
7405
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
7406
|
+
* All rights reserved.
|
|
7407
|
+
* SPDX-License-Identifier: MIT
|
|
7408
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7409
|
+
*/
|
|
7410
|
+
function isCustomElementRegistryAvailable() {
|
|
7411
|
+
if (typeof customElements === 'undefined') {
|
|
7412
|
+
return false;
|
|
7413
|
+
}
|
|
7414
|
+
try {
|
|
7415
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
7416
|
+
// _wrapNativeSuper()
|
|
7417
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
|
|
7418
|
+
// get wrapped by babel.
|
|
7419
|
+
const HTMLElementAlias = HTMLElement;
|
|
7420
|
+
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7421
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7422
|
+
// which are not equipped to be initialized that way.
|
|
7423
|
+
class clazz extends HTMLElementAlias {
|
|
7424
|
+
}
|
|
7425
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7426
|
+
new clazz();
|
|
7427
|
+
return true;
|
|
7428
|
+
}
|
|
7429
|
+
catch (_a) {
|
|
7430
|
+
return false;
|
|
7431
|
+
}
|
|
7432
|
+
}
|
|
7433
|
+
const hasCustomElements = isCustomElementRegistryAvailable();
|
|
7434
|
+
|
|
7435
|
+
/*
|
|
7436
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7437
|
+
* All rights reserved.
|
|
7438
|
+
* SPDX-License-Identifier: MIT
|
|
7439
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7440
|
+
*/
|
|
7441
|
+
// Creates a custom element for compat (legacy) browser environments
|
|
7442
|
+
const createCustomElementCompat = (tagName, upgradeCallback) => {
|
|
7443
|
+
const elm = document.createElement(tagName);
|
|
7444
|
+
upgradeCallback(elm); // nothing to do with the result for now
|
|
7445
|
+
return elm;
|
|
7446
|
+
};
|
|
7447
|
+
|
|
7448
|
+
/*
|
|
7449
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7450
|
+
* All rights reserved.
|
|
7451
|
+
* SPDX-License-Identifier: MIT
|
|
7452
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7453
|
+
*/
|
|
7454
|
+
const cachedConstructors = new Map();
|
|
7455
|
+
const elementsUpgradedOutsideLWC = new WeakSet();
|
|
7456
|
+
let elementBeingUpgradedByLWC = false;
|
|
7457
|
+
// Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
|
|
7458
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
|
7459
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
|
7460
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
|
7461
|
+
// This class should be created once per tag name.
|
|
7462
|
+
const createUpgradableConstructor = (connectedCallback, disconnectedCallback) => {
|
|
7463
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
7464
|
+
return class UpgradableConstructor extends HTMLElement {
|
|
7465
|
+
constructor(upgradeCallback) {
|
|
7466
|
+
super();
|
|
7467
|
+
// If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
|
|
7468
|
+
// then elementBeingUpgraded will be false
|
|
7469
|
+
if (elementBeingUpgradedByLWC) {
|
|
7470
|
+
upgradeCallback(this);
|
|
7471
|
+
}
|
|
7472
|
+
else {
|
|
7473
|
+
// keep track of elements that were not created by lwc.createElement,
|
|
7474
|
+
// so we can ignore their lifecycle hooks
|
|
7475
|
+
elementsUpgradedOutsideLWC.add(this);
|
|
7476
|
+
// TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
|
7477
|
+
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
|
7478
|
+
}
|
|
7479
|
+
}
|
|
7480
|
+
connectedCallback() {
|
|
7481
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
7482
|
+
connectedCallback(this);
|
|
7483
|
+
}
|
|
7484
|
+
}
|
|
7485
|
+
disconnectedCallback() {
|
|
7486
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
7487
|
+
disconnectedCallback(this);
|
|
7488
|
+
}
|
|
7489
|
+
}
|
|
7490
|
+
};
|
|
7491
|
+
};
|
|
7492
|
+
const createCustomElementVanilla = (tagName, upgradeCallback, connectedCallback, disconnectedCallback) => {
|
|
7493
|
+
// use global custom elements registry
|
|
7494
|
+
let UpgradableConstructor = cachedConstructors.get(tagName);
|
|
7495
|
+
if (isUndefined$1(UpgradableConstructor)) {
|
|
7496
|
+
if (!isUndefined$1(customElements.get(tagName))) {
|
|
7497
|
+
throw new Error(`Unexpected tag name "${tagName}". This name is a registered custom element, preventing LWC to upgrade the element.`);
|
|
7498
|
+
}
|
|
7499
|
+
UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
|
|
7500
|
+
customElements.define(tagName, UpgradableConstructor);
|
|
7501
|
+
cachedConstructors.set(tagName, UpgradableConstructor);
|
|
7502
|
+
}
|
|
7503
|
+
elementBeingUpgradedByLWC = true;
|
|
7504
|
+
try {
|
|
7505
|
+
return new UpgradableConstructor(upgradeCallback);
|
|
7506
|
+
}
|
|
7507
|
+
finally {
|
|
7508
|
+
elementBeingUpgradedByLWC = false;
|
|
7509
|
+
}
|
|
7510
|
+
};
|
|
7511
|
+
|
|
7512
|
+
/*
|
|
7513
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
7514
|
+
* All rights reserved.
|
|
7515
|
+
* SPDX-License-Identifier: MIT
|
|
7516
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7517
|
+
*/
|
|
7518
|
+
/**
|
|
7519
|
+
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
7520
|
+
* do not conflict with vanilla custom elements having the same tag name.
|
|
7521
|
+
*/
|
|
7522
|
+
function createScopedRegistry() {
|
|
7523
|
+
if (!hasCustomElements) {
|
|
7524
|
+
// This code should never be reached, because we don't use the pivot registry if
|
|
7525
|
+
// custom elements are unavailable.
|
|
7526
|
+
throw new Error('Custom elements are not supported in this environment.');
|
|
7527
|
+
}
|
|
7528
|
+
const { HTMLElement: NativeHTMLElement } = window;
|
|
7529
|
+
const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
|
|
7530
|
+
const definitionForElement = new WeakMap();
|
|
7531
|
+
const pendingRegistryForElement = new WeakMap();
|
|
7532
|
+
const definitionForConstructor = new WeakMap();
|
|
7533
|
+
const registeredUserCtors = new WeakSet();
|
|
7534
|
+
const pivotCtorByTag = new Map();
|
|
7535
|
+
const globalDefinitionsByTag = new Map();
|
|
7536
|
+
const globalDefinitionsByClass = new Map();
|
|
7537
|
+
const awaitingUpgrade = new Map();
|
|
7538
|
+
const EMPTY_SET = new Set();
|
|
7539
|
+
function createDefinitionRecord(constructor) {
|
|
7540
|
+
var _a;
|
|
7541
|
+
const { connectedCallback, disconnectedCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
|
|
7542
|
+
const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
7543
|
+
return {
|
|
7544
|
+
UserCtor: constructor,
|
|
7545
|
+
PivotCtor: undefined,
|
|
7546
|
+
connectedCallback,
|
|
7547
|
+
disconnectedCallback,
|
|
7548
|
+
adoptedCallback,
|
|
7549
|
+
attributeChangedCallback,
|
|
7550
|
+
observedAttributes,
|
|
7551
|
+
};
|
|
7552
|
+
}
|
|
7553
|
+
// Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
7554
|
+
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
7555
|
+
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
7556
|
+
// constructor is invoked with another constructor.
|
|
7557
|
+
function createPivotingClass(tagName, registeredDefinition) {
|
|
7558
|
+
class PivotCtor extends NativeHTMLElement {
|
|
7559
|
+
constructor(UserCtor) {
|
|
7560
|
+
// This constructor can only be invoked by:
|
|
7561
|
+
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
7562
|
+
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
7563
|
+
// b) new UserClass.
|
|
7564
|
+
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
7565
|
+
// If the caller signals via UserCtor that this is in fact a controlled
|
|
7566
|
+
// definition, we use that one, otherwise fallback to the global
|
|
7567
|
+
// internal registry.
|
|
7568
|
+
super();
|
|
7569
|
+
const userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
7570
|
+
if (userCtorIsDefined) {
|
|
7571
|
+
if (!isConstructor(UserCtor)) {
|
|
7572
|
+
throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
|
|
7573
|
+
}
|
|
7574
|
+
if (!registeredUserCtors.has(UserCtor)) {
|
|
7575
|
+
throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
|
|
7576
|
+
}
|
|
7577
|
+
}
|
|
7578
|
+
const definition = userCtorIsDefined
|
|
7579
|
+
? getOrCreateDefinitionForConstructor(UserCtor)
|
|
7580
|
+
: globalDefinitionsByTag.get(tagName);
|
|
7581
|
+
if (!isUndefined$1(definition)) {
|
|
7582
|
+
internalUpgrade(this, registeredDefinition, definition);
|
|
7583
|
+
}
|
|
7584
|
+
else {
|
|
7585
|
+
// This is the case in which there is no global definition, and
|
|
7586
|
+
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
7587
|
+
// so we need to add it to the pending queue just in case it eventually
|
|
7588
|
+
// gets defined in the global registry.
|
|
7589
|
+
pendingRegistryForElement.set(this, registeredDefinition);
|
|
7590
|
+
}
|
|
7591
|
+
}
|
|
7592
|
+
connectedCallback() {
|
|
7593
|
+
var _a;
|
|
7594
|
+
const definition = definitionForElement.get(this);
|
|
7595
|
+
if (!isUndefined$1(definition)) {
|
|
7596
|
+
// Delegate out to user callback
|
|
7597
|
+
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7598
|
+
}
|
|
7599
|
+
else {
|
|
7600
|
+
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
7601
|
+
let awaiting = awaitingUpgrade.get(tagName);
|
|
7602
|
+
if (isUndefined$1(awaiting)) {
|
|
7603
|
+
awaitingUpgrade.set(tagName, (awaiting = new Set()));
|
|
7604
|
+
}
|
|
7605
|
+
awaiting.add(this);
|
|
7606
|
+
}
|
|
7607
|
+
}
|
|
7608
|
+
disconnectedCallback() {
|
|
7609
|
+
var _a;
|
|
7610
|
+
const definition = definitionForElement.get(this);
|
|
7611
|
+
if (!isUndefined$1(definition)) {
|
|
7612
|
+
// Delegate out to user callback
|
|
7613
|
+
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7614
|
+
}
|
|
7615
|
+
else {
|
|
7616
|
+
// Un-register for upgrade when defined (so we don't leak)
|
|
7617
|
+
const awaiting = awaitingUpgrade.get(tagName);
|
|
7618
|
+
// At this point, awaiting should never be undefined, because connectedCallback
|
|
7619
|
+
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
7620
|
+
if (!isUndefined$1(awaiting)) {
|
|
7621
|
+
awaiting.delete(this);
|
|
7622
|
+
}
|
|
7623
|
+
}
|
|
7624
|
+
}
|
|
7625
|
+
adoptedCallback() {
|
|
7626
|
+
var _a;
|
|
7627
|
+
const definition = definitionForElement.get(this);
|
|
7628
|
+
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7629
|
+
}
|
|
7630
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
7631
|
+
var _a;
|
|
7632
|
+
const definition = definitionForElement.get(this);
|
|
7633
|
+
// if both definitions are the same, then the observedAttributes is the same,
|
|
7634
|
+
// but if they are different, only if the runtime definition has the attribute
|
|
7635
|
+
// marked as observed, then it should invoke attributeChangedCallback.
|
|
7636
|
+
if (registeredDefinition === definition ||
|
|
7637
|
+
(definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
7638
|
+
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
7639
|
+
}
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
|
|
7643
|
+
return PivotCtor;
|
|
7644
|
+
}
|
|
7645
|
+
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
7646
|
+
const { observedAttributes, attributeChangedCallback } = pivotDefinition;
|
|
7647
|
+
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
7648
|
+
// This instance does not need to observe any attributes, no need to patch
|
|
7649
|
+
return EMPTY_SET;
|
|
7650
|
+
}
|
|
7651
|
+
// Natively, the attributes observed by the registered definition are going to be taken
|
|
7652
|
+
// care of by the browser, only the difference between the two sets has to be taken
|
|
7653
|
+
// care by the patched version.
|
|
7654
|
+
return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
|
|
7655
|
+
}
|
|
7656
|
+
function throwAsyncError(error) {
|
|
7657
|
+
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
7658
|
+
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
7659
|
+
// to make it an unhandled error rather than an unhandled rejection.
|
|
7660
|
+
setTimeout(() => {
|
|
7661
|
+
throw error;
|
|
7662
|
+
});
|
|
7663
|
+
}
|
|
7664
|
+
// Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
7665
|
+
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
7666
|
+
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
7667
|
+
// and the second class observes attributes that aren't observed by the first one,
|
|
7668
|
+
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
7669
|
+
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
7670
|
+
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
7671
|
+
// that we aren't observing the attributes we need to.
|
|
7672
|
+
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
7673
|
+
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7674
|
+
if (newObservedAttributes.size === 0) {
|
|
7675
|
+
return;
|
|
7676
|
+
}
|
|
7677
|
+
const { attributeChangedCallback } = pivotDefinition;
|
|
7678
|
+
// Patch the instance.
|
|
7679
|
+
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
7680
|
+
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
7681
|
+
// `setAttribute` and `removeAttribute`.
|
|
7682
|
+
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
7683
|
+
defineProperties(instance, {
|
|
7684
|
+
setAttribute: {
|
|
7685
|
+
value: function setAttribute(name, value) {
|
|
7686
|
+
if (newObservedAttributes.has(name)) {
|
|
7687
|
+
const old = nativeGetAttribute.call(this, name);
|
|
7688
|
+
nativeSetAttribute.call(this, name, value);
|
|
7689
|
+
try {
|
|
7690
|
+
attributeChangedCallback.call(this, name, old, value + '');
|
|
7691
|
+
}
|
|
7692
|
+
catch (error) {
|
|
7693
|
+
throwAsyncError(error);
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7696
|
+
else {
|
|
7697
|
+
nativeSetAttribute.call(this, name, value);
|
|
7698
|
+
}
|
|
7699
|
+
},
|
|
7700
|
+
writable: true,
|
|
7701
|
+
enumerable: true,
|
|
7702
|
+
configurable: true,
|
|
7703
|
+
},
|
|
7704
|
+
removeAttribute: {
|
|
7705
|
+
value: function removeAttribute(name) {
|
|
7706
|
+
if (newObservedAttributes.has(name)) {
|
|
7707
|
+
const old = nativeGetAttribute.call(this, name);
|
|
7708
|
+
nativeRemoveAttribute.call(this, name);
|
|
7709
|
+
try {
|
|
7710
|
+
attributeChangedCallback.call(this, name, old, null);
|
|
7711
|
+
}
|
|
7712
|
+
catch (error) {
|
|
7713
|
+
throwAsyncError(error);
|
|
7714
|
+
}
|
|
7715
|
+
}
|
|
7716
|
+
else {
|
|
7717
|
+
nativeRemoveAttribute.call(this, name);
|
|
7718
|
+
}
|
|
7719
|
+
},
|
|
7720
|
+
writable: true,
|
|
7721
|
+
enumerable: true,
|
|
7722
|
+
configurable: true,
|
|
7723
|
+
},
|
|
7724
|
+
});
|
|
7725
|
+
}
|
|
7726
|
+
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7727
|
+
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
7728
|
+
// from a pre-existing one in the DOM.
|
|
7729
|
+
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7730
|
+
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
7731
|
+
return;
|
|
7732
|
+
}
|
|
7733
|
+
const { attributeChangedCallback } = pivotDefinition;
|
|
7734
|
+
// Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
7735
|
+
newObservedAttributes.forEach((name) => {
|
|
7736
|
+
if (nativeHasAttribute.call(instance, name)) {
|
|
7737
|
+
const newValue = nativeGetAttribute.call(instance, name);
|
|
7738
|
+
attributeChangedCallback.call(instance, name, null, newValue);
|
|
7739
|
+
}
|
|
7740
|
+
});
|
|
7741
|
+
}
|
|
7742
|
+
// User extends this HTMLElement, which returns the CE being upgraded
|
|
7743
|
+
let upgradingInstance;
|
|
7744
|
+
// Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
7745
|
+
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7746
|
+
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
7747
|
+
definitionForElement.set(instance, pivotDefinition);
|
|
7748
|
+
// attributes patches when needed
|
|
7749
|
+
if (pivotDefinition !== registeredDefinition) {
|
|
7750
|
+
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
7751
|
+
}
|
|
7752
|
+
// Tricking the construction path to believe that a new instance is being created,
|
|
7753
|
+
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
7754
|
+
// constructor will reuse the instance by returning the upgradingInstance.
|
|
7755
|
+
// This is by far the most important piece of the puzzle
|
|
7756
|
+
upgradingInstance = instance;
|
|
7757
|
+
// By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
7758
|
+
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
7759
|
+
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
7760
|
+
new pivotDefinition.UserCtor();
|
|
7761
|
+
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
7762
|
+
}
|
|
7763
|
+
function isConstructor(constructor) {
|
|
7764
|
+
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
7765
|
+
}
|
|
7766
|
+
function getOrCreateDefinitionForConstructor(constructor) {
|
|
7767
|
+
if (!isConstructor(constructor)) {
|
|
7768
|
+
throw new TypeError('The referenced constructor is not a constructor.');
|
|
7769
|
+
}
|
|
7770
|
+
const definition = definitionForConstructor.get(constructor);
|
|
7771
|
+
if (!isUndefined$1(definition)) {
|
|
7772
|
+
return definition;
|
|
7773
|
+
}
|
|
7774
|
+
return createDefinitionRecord(constructor);
|
|
7775
|
+
}
|
|
7776
|
+
const { customElements: nativeRegistry } = window;
|
|
7777
|
+
const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
|
|
7778
|
+
// patch for the global registry define mechanism
|
|
7779
|
+
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
7780
|
+
if (options && options.extends) {
|
|
7781
|
+
// TODO [#2983]: should we support `extends`?
|
|
7782
|
+
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
7783
|
+
}
|
|
7784
|
+
if (globalDefinitionsByTag.has(tagName)) {
|
|
7785
|
+
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
|
|
7786
|
+
}
|
|
7787
|
+
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
7788
|
+
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
|
|
7789
|
+
}
|
|
7790
|
+
const definition = getOrCreateDefinitionForConstructor(constructor);
|
|
7791
|
+
registeredUserCtors.add(constructor);
|
|
7792
|
+
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
7793
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7794
|
+
PivotCtor = createPivotingClass(tagName, definition);
|
|
7795
|
+
// Register a pivoting class which will handle global registry initializations
|
|
7796
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7797
|
+
}
|
|
7798
|
+
// Only cache after nativeDefine has been called, because if it throws an error
|
|
7799
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7800
|
+
definitionForConstructor.set(constructor, definition);
|
|
7801
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7802
|
+
globalDefinitionsByTag.set(tagName, definition);
|
|
7803
|
+
globalDefinitionsByClass.set(constructor, definition);
|
|
7804
|
+
// For globally defined custom elements, the definition associated
|
|
7805
|
+
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
7806
|
+
// new the UserCtor, so we know how to create the underlying element.
|
|
7807
|
+
definition.PivotCtor = PivotCtor;
|
|
7808
|
+
// Upgrade any elements created in this scope before customElements.define
|
|
7809
|
+
// was called, which should be exhibited by the following steps:
|
|
7810
|
+
// 1) LWC registers a tagName for an LWC component.
|
|
7811
|
+
// 2) Element with same tagName is created with document.createElement()
|
|
7812
|
+
// and inserted into DOM.
|
|
7813
|
+
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
7814
|
+
// This requires immediate upgrade when the new global tagName is defined.
|
|
7815
|
+
const awaiting = awaitingUpgrade.get(tagName);
|
|
7816
|
+
if (!isUndefined$1(awaiting)) {
|
|
7817
|
+
awaitingUpgrade.delete(tagName);
|
|
7818
|
+
for (const element of awaiting) {
|
|
7819
|
+
const registeredDefinition = pendingRegistryForElement.get(element);
|
|
7820
|
+
// At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
7821
|
+
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
7822
|
+
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
7823
|
+
// But just to be safe, we check.
|
|
7824
|
+
if (!isUndefined$1(registeredDefinition)) {
|
|
7825
|
+
pendingRegistryForElement.delete(element);
|
|
7826
|
+
internalUpgrade(element, registeredDefinition, definition);
|
|
7827
|
+
}
|
|
7828
|
+
}
|
|
7829
|
+
}
|
|
7830
|
+
};
|
|
7831
|
+
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
7832
|
+
const NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
7833
|
+
if (!isUndefined$1(NativeCtor)) {
|
|
7834
|
+
const definition = globalDefinitionsByTag.get(tagName);
|
|
7835
|
+
if (!isUndefined$1(definition)) {
|
|
7836
|
+
return definition.UserCtor; // defined by the patched custom elements registry
|
|
7837
|
+
}
|
|
7838
|
+
// TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7839
|
+
return NativeCtor; // return the pivot constructor or constructor that existed before patching
|
|
7840
|
+
}
|
|
7841
|
+
};
|
|
7842
|
+
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
7843
|
+
return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
|
|
7844
|
+
const definition = globalDefinitionsByTag.get(tagName);
|
|
7845
|
+
if (!isUndefined$1(definition)) {
|
|
7846
|
+
return definition.UserCtor;
|
|
7847
|
+
}
|
|
7848
|
+
// TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7849
|
+
// In this case, the custom element must have been defined before the registry patches
|
|
7850
|
+
// were applied. So return the non-pivot constructor
|
|
7851
|
+
if (isUndefined$1(NativeCtor)) {
|
|
7852
|
+
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
7853
|
+
// We can patch the correct behavior using customElements.get()
|
|
7854
|
+
return nativeGet.call(nativeRegistry, tagName);
|
|
7855
|
+
}
|
|
7856
|
+
return NativeCtor;
|
|
7857
|
+
});
|
|
7858
|
+
};
|
|
7859
|
+
// This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
7860
|
+
// @ts-ignore
|
|
7861
|
+
window.HTMLElement = function HTMLElement() {
|
|
7862
|
+
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
7863
|
+
// native custom elements and we're in the process of running the
|
|
7864
|
+
// "constructor-call trick" on the natively constructed instance, so just
|
|
7865
|
+
// return that here.
|
|
7866
|
+
// This code path is also called when LWC `new`s a PivotCtor.
|
|
7867
|
+
const instance = upgradingInstance;
|
|
7868
|
+
if (!isUndefined$1(instance)) {
|
|
7869
|
+
upgradingInstance = undefined;
|
|
7870
|
+
return instance;
|
|
7871
|
+
}
|
|
7872
|
+
// Construction case: we need to construct the pivoting instance and return it.
|
|
7873
|
+
// This is possible when the user register it via global registry and instantiate
|
|
7874
|
+
// it via `new Ctor()`.
|
|
7875
|
+
const { constructor } = this;
|
|
7876
|
+
const definition = globalDefinitionsByClass.get(constructor);
|
|
7877
|
+
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
7878
|
+
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
7879
|
+
// doing `customElements.define()` first. This matches native browser behavior:
|
|
7880
|
+
// https://stackoverflow.com/a/61883392
|
|
7881
|
+
throw new TypeError('Illegal constructor');
|
|
7882
|
+
}
|
|
7883
|
+
// This constructor is ONLY invoked when it is the user instantiating
|
|
7884
|
+
// an element via new Ctor while Ctor is a registered global constructor.
|
|
7885
|
+
const { PivotCtor, UserCtor } = definition;
|
|
7886
|
+
return new PivotCtor(UserCtor);
|
|
7887
|
+
};
|
|
7888
|
+
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
7889
|
+
/**
|
|
7890
|
+
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
7891
|
+
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
7892
|
+
* is a hint that can be used when registering a custom element with the global custom elements
|
|
7893
|
+
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
7894
|
+
* as "safe" to be used when passed in to a PivotConstructor.
|
|
7895
|
+
*
|
|
7896
|
+
* @param tagName - element tag name
|
|
7897
|
+
* @param UserCtor - userland custom element constructor
|
|
7898
|
+
* @returns a new custom element constructor
|
|
7899
|
+
*/
|
|
7900
|
+
return function createPivotConstructor(tagName, UserCtor) {
|
|
7901
|
+
tagName = StringToLowerCase.call(tagName);
|
|
7902
|
+
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
7903
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7904
|
+
const definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
7905
|
+
PivotCtor = createPivotingClass(tagName, definition);
|
|
7906
|
+
// Register a pivoting class as a global custom element
|
|
7907
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7908
|
+
definition.PivotCtor = PivotCtor;
|
|
7909
|
+
// Only cache after nativeDefine has been called, because if it throws an error
|
|
7910
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7911
|
+
definitionForConstructor.set(UserCtor, definition);
|
|
7912
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7913
|
+
}
|
|
7914
|
+
// Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
7915
|
+
registeredUserCtors.add(UserCtor);
|
|
7916
|
+
return PivotCtor;
|
|
7917
|
+
};
|
|
7918
|
+
}
|
|
7919
|
+
|
|
7920
|
+
/*
|
|
7921
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7922
|
+
* All rights reserved.
|
|
7923
|
+
* SPDX-License-Identifier: MIT
|
|
7924
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7925
|
+
*/
|
|
7926
|
+
let createScopedConstructor;
|
|
7927
|
+
let CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
7928
|
+
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
7929
|
+
// or we're in a legacy browser.
|
|
7930
|
+
|
|
7931
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
7932
|
+
if (hasCustomElements) {
|
|
7933
|
+
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
7934
|
+
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
7935
|
+
//
|
|
7936
|
+
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
7937
|
+
//
|
|
7938
|
+
// 1. LWC loads
|
|
7939
|
+
// 2. `const Ctor = class extends HTMLElement {}`
|
|
7940
|
+
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
7941
|
+
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
7942
|
+
//
|
|
7943
|
+
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
7944
|
+
createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
7945
|
+
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
7946
|
+
// because the HTMLElement prototypes are mixed up.
|
|
7947
|
+
//
|
|
7948
|
+
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
7949
|
+
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
7950
|
+
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
7951
|
+
// Caching avoids this problem.
|
|
7952
|
+
|
|
7953
|
+
CachedHTMLElement = window.HTMLElement;
|
|
7954
|
+
}
|
|
7955
|
+
} // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
7956
|
+
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
7957
|
+
// multiple times per tag name.
|
|
7958
|
+
|
|
7959
|
+
|
|
7960
|
+
const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
|
|
7961
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
7962
|
+
return class UserConstructor extends HTMLElementToExtend {
|
|
7963
|
+
constructor() {
|
|
7964
|
+
super();
|
|
7965
|
+
upgradeCallback(this);
|
|
7966
|
+
}
|
|
7967
|
+
|
|
7968
|
+
connectedCallback() {
|
|
7969
|
+
connectedCallback(this);
|
|
7970
|
+
}
|
|
7971
|
+
|
|
7972
|
+
disconnectedCallback() {
|
|
7973
|
+
disconnectedCallback(this);
|
|
7974
|
+
}
|
|
7975
|
+
|
|
7976
|
+
};
|
|
7977
|
+
};
|
|
7978
|
+
|
|
7979
|
+
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
7980
|
+
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
7981
|
+
// This error should be impossible to hit
|
|
7982
|
+
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
7983
|
+
}
|
|
7984
|
+
|
|
7985
|
+
const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
7986
|
+
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
7987
|
+
return new ScopedConstructor(UserConstructor);
|
|
7988
|
+
}
|
|
7989
|
+
|
|
7990
|
+
/*
|
|
7991
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7992
|
+
* All rights reserved.
|
|
7993
|
+
* SPDX-License-Identifier: MIT
|
|
7994
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7995
|
+
*/
|
|
7996
|
+
/**
|
|
7997
|
+
* We have three modes for creating custom elements:
|
|
7998
|
+
*
|
|
7999
|
+
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
8000
|
+
* 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
|
|
8001
|
+
* same tag name, via a simple trick: every custom element constructor we define in the registry is basically
|
|
8002
|
+
* the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
|
|
8003
|
+
* constructor, which allows us to have completely customized functionality for different components.
|
|
8004
|
+
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
8005
|
+
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
8006
|
+
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
8007
|
+
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
8008
|
+
*/
|
|
8009
|
+
|
|
8010
|
+
let createCustomElement;
|
|
8011
|
+
|
|
8012
|
+
if (hasCustomElements) {
|
|
8013
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8014
|
+
createCustomElement = createCustomElementScoped;
|
|
8015
|
+
} else {
|
|
8016
|
+
// use global custom elements registry (vanilla)
|
|
8017
|
+
createCustomElement = createCustomElementVanilla;
|
|
8018
|
+
}
|
|
8019
|
+
} else {
|
|
8020
|
+
// no registry available here
|
|
8021
|
+
createCustomElement = createCustomElementCompat;
|
|
8022
|
+
}
|
|
8023
|
+
|
|
7414
8024
|
/*
|
|
7415
8025
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7416
8026
|
* All rights reserved.
|
|
@@ -7471,7 +8081,7 @@
|
|
|
7471
8081
|
function isNull(obj) {
|
|
7472
8082
|
return obj === null;
|
|
7473
8083
|
}
|
|
7474
|
-
/** version: 2.
|
|
8084
|
+
/** version: 2.26.0 */
|
|
7475
8085
|
|
|
7476
8086
|
/*
|
|
7477
8087
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7479,65 +8089,6 @@
|
|
|
7479
8089
|
* SPDX-License-Identifier: MIT
|
|
7480
8090
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7481
8091
|
*/
|
|
7482
|
-
exports.getCustomElement = void 0;
|
|
7483
|
-
exports.defineCustomElement = void 0;
|
|
7484
|
-
let HTMLElementConstructor;
|
|
7485
|
-
function isCustomElementRegistryAvailable() {
|
|
7486
|
-
if (typeof customElements === 'undefined') {
|
|
7487
|
-
return false;
|
|
7488
|
-
}
|
|
7489
|
-
try {
|
|
7490
|
-
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
7491
|
-
// _wrapNativeSuper()
|
|
7492
|
-
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
7493
|
-
// get wrapped by babel.
|
|
7494
|
-
const HTMLElementAlias = HTMLElement;
|
|
7495
|
-
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7496
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7497
|
-
// which are not equipped to be initialized that way.
|
|
7498
|
-
class clazz extends HTMLElementAlias {
|
|
7499
|
-
}
|
|
7500
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7501
|
-
new clazz();
|
|
7502
|
-
return true;
|
|
7503
|
-
}
|
|
7504
|
-
catch (_a) {
|
|
7505
|
-
return false;
|
|
7506
|
-
}
|
|
7507
|
-
}
|
|
7508
|
-
if (isCustomElementRegistryAvailable()) {
|
|
7509
|
-
exports.getCustomElement = customElements.get.bind(customElements);
|
|
7510
|
-
exports.defineCustomElement = customElements.define.bind(customElements);
|
|
7511
|
-
HTMLElementConstructor = HTMLElement;
|
|
7512
|
-
}
|
|
7513
|
-
else {
|
|
7514
|
-
const registry = Object.create(null);
|
|
7515
|
-
const reverseRegistry = new WeakMap();
|
|
7516
|
-
exports.defineCustomElement = function define(name, ctor) {
|
|
7517
|
-
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
7518
|
-
throw new TypeError(`Invalid Registration`);
|
|
7519
|
-
}
|
|
7520
|
-
registry[name] = ctor;
|
|
7521
|
-
reverseRegistry.set(ctor, name);
|
|
7522
|
-
};
|
|
7523
|
-
exports.getCustomElement = function get(name) {
|
|
7524
|
-
return registry[name];
|
|
7525
|
-
};
|
|
7526
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
7527
|
-
if (!(this instanceof HTMLElement)) {
|
|
7528
|
-
throw new TypeError(`Invalid Invocation`);
|
|
7529
|
-
}
|
|
7530
|
-
const { constructor } = this;
|
|
7531
|
-
const name = reverseRegistry.get(constructor);
|
|
7532
|
-
if (!name) {
|
|
7533
|
-
throw new TypeError(`Invalid Construction`);
|
|
7534
|
-
}
|
|
7535
|
-
const elm = document.createElement(name);
|
|
7536
|
-
Object.setPrototypeOf(elm, constructor.prototype);
|
|
7537
|
-
return elm;
|
|
7538
|
-
};
|
|
7539
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7540
|
-
}
|
|
7541
8092
|
function cloneNode(node, deep) {
|
|
7542
8093
|
return node.cloneNode(deep);
|
|
7543
8094
|
}
|
|
@@ -7711,9 +8262,7 @@
|
|
|
7711
8262
|
function assertInstanceOfHTMLElement(elm, msg) {
|
|
7712
8263
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7713
8264
|
}
|
|
7714
|
-
const HTMLElementExported = HTMLElementConstructor;
|
|
7715
8265
|
|
|
7716
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
7717
8266
|
exports.addEventListener = addEventListener;
|
|
7718
8267
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
7719
8268
|
exports.attachShadow = attachShadow;
|
|
@@ -7773,6 +8322,8 @@
|
|
|
7773
8322
|
{
|
|
7774
8323
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7775
8324
|
insertStylesheet,
|
|
8325
|
+
// relies on a shared global cache
|
|
8326
|
+
createCustomElement,
|
|
7776
8327
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7777
8328
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7778
8329
|
});
|
|
@@ -7873,36 +8424,44 @@
|
|
|
7873
8424
|
// This WeakSet usage is valid because this functionality is not meant to run in IE11.
|
|
7874
8425
|
const hydratedCustomElements = new WeakSet();
|
|
7875
8426
|
function buildCustomElementConstructor(Ctor) {
|
|
8427
|
+
var _a;
|
|
7876
8428
|
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
8429
|
+
const { observedAttributes } = HtmlPrototype;
|
|
8430
|
+
const { attributeChangedCallback } = HtmlPrototype.prototype;
|
|
8431
|
+
return _a = class extends HTMLElement {
|
|
8432
|
+
constructor() {
|
|
8433
|
+
super();
|
|
8434
|
+
if (this.isConnected) {
|
|
8435
|
+
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
8436
|
+
hydrateComponent(this, Ctor, {});
|
|
8437
|
+
hydratedCustomElements.add(this);
|
|
8438
|
+
}
|
|
8439
|
+
else {
|
|
8440
|
+
createVM(this, Ctor, renderer, {
|
|
8441
|
+
mode: 'open',
|
|
8442
|
+
owner: null,
|
|
8443
|
+
tagName: this.tagName,
|
|
8444
|
+
});
|
|
8445
|
+
}
|
|
7884
8446
|
}
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
8447
|
+
connectedCallback() {
|
|
8448
|
+
if (hydratedCustomElements.has(this)) {
|
|
8449
|
+
// This is an un-upgraded element that was hydrated in the constructor.
|
|
8450
|
+
hydratedCustomElements.delete(this);
|
|
8451
|
+
}
|
|
8452
|
+
else {
|
|
8453
|
+
connectRootElement(this);
|
|
8454
|
+
}
|
|
7891
8455
|
}
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
if (hydratedCustomElements.has(this)) {
|
|
7895
|
-
// This is an un-upgraded element that was hydrated in the constructor.
|
|
7896
|
-
hydratedCustomElements.delete(this);
|
|
8456
|
+
disconnectedCallback() {
|
|
8457
|
+
disconnectRootElement(this);
|
|
7897
8458
|
}
|
|
7898
|
-
|
|
7899
|
-
|
|
8459
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
8460
|
+
attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
7900
8461
|
}
|
|
7901
|
-
}
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
}
|
|
7905
|
-
};
|
|
8462
|
+
},
|
|
8463
|
+
_a.observedAttributes = observedAttributes,
|
|
8464
|
+
_a;
|
|
7906
8465
|
}
|
|
7907
8466
|
|
|
7908
8467
|
/*
|
|
@@ -7989,8 +8548,13 @@
|
|
|
7989
8548
|
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
7990
8549
|
}
|
|
7991
8550
|
|
|
7992
|
-
const
|
|
7993
|
-
|
|
8551
|
+
const {
|
|
8552
|
+
createCustomElement
|
|
8553
|
+
} = renderer; // tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
8554
|
+
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
8555
|
+
// the following line guarantees that this does not leaks beyond this point.
|
|
8556
|
+
|
|
8557
|
+
const tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
|
|
7994
8558
|
|
|
7995
8559
|
/**
|
|
7996
8560
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -7999,9 +8563,9 @@
|
|
|
7999
8563
|
* an upgradable custom element.
|
|
8000
8564
|
*/
|
|
8001
8565
|
|
|
8002
|
-
const
|
|
8566
|
+
const upgradeCallback = elm => {
|
|
8003
8567
|
createVM(elm, Ctor, renderer, {
|
|
8004
|
-
tagName
|
|
8568
|
+
tagName,
|
|
8005
8569
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
8006
8570
|
owner: null
|
|
8007
8571
|
});
|
|
@@ -8010,15 +8574,21 @@
|
|
|
8010
8574
|
ConnectingSlot.set(elm, connectRootElement);
|
|
8011
8575
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
8012
8576
|
}
|
|
8577
|
+
};
|
|
8013
8578
|
|
|
8014
|
-
|
|
8015
|
-
|
|
8579
|
+
const connectedCallback = elm => {
|
|
8580
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8581
|
+
connectRootElement(elm);
|
|
8582
|
+
}
|
|
8583
|
+
};
|
|
8016
8584
|
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8585
|
+
const disconnectedCallback = elm => {
|
|
8586
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8587
|
+
disconnectRootElement(elm);
|
|
8588
|
+
}
|
|
8589
|
+
};
|
|
8021
8590
|
|
|
8591
|
+
const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
8022
8592
|
return element;
|
|
8023
8593
|
}
|
|
8024
8594
|
|
|
@@ -8090,7 +8660,7 @@
|
|
|
8090
8660
|
});
|
|
8091
8661
|
freeze(LightningElement);
|
|
8092
8662
|
seal(LightningElement.prototype);
|
|
8093
|
-
/* version: 2.
|
|
8663
|
+
/* version: 2.26.0 */
|
|
8094
8664
|
|
|
8095
8665
|
exports.LightningElement = LightningElement;
|
|
8096
8666
|
exports.__unstable__ProfilerControl = profilerControl;
|