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