lwc 2.25.1 → 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.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +885 -411
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +885 -411
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +731 -205
  5. package/dist/engine-dom/iife/es5/engine-dom.js +954 -311
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +883 -224
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +885 -411
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +731 -205
  11. package/dist/engine-dom/umd/es5/engine-dom.js +954 -311
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +883 -224
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +133 -227
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +133 -227
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.25.1";
302
+ const LWC_VERSION = "2.26.0";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.25.1 */
304
+ /** version: 2.26.0 */
305
305
 
306
306
  /**
307
307
  * Copyright (C) 2018 salesforce.com, inc.
@@ -383,7 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
383
383
  patch$1(propName);
384
384
  }
385
385
  }
386
- /** version: 2.25.1 */
386
+ /** version: 2.26.0 */
387
387
 
388
388
  /**
389
389
  * Copyright (C) 2018 salesforce.com, inc.
@@ -399,7 +399,6 @@ const features = {
399
399
  DUMMY_TEST_FLAG: null,
400
400
  ENABLE_ELEMENT_PATCH: null,
401
401
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
402
- ENABLE_HMR: null,
403
402
  ENABLE_HTML_COLLECTIONS_PATCH: null,
404
403
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
405
404
  ENABLE_MIXED_SHADOW_MODE: null,
@@ -410,6 +409,7 @@ const features = {
410
409
  ENABLE_WIRE_SYNC_EMIT: null,
411
410
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
412
411
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
412
+ ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
413
413
  };
414
414
  if (!_globalThis.lwcRuntimeFlags) {
415
415
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -463,7 +463,7 @@ function setFeatureFlagForTest(name, value) {
463
463
  setFeatureFlag(name, value);
464
464
  }
465
465
  }
466
- /** version: 2.25.1 */
466
+ /** version: 2.26.0 */
467
467
 
468
468
  /*
469
469
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1937,7 +1937,9 @@ const refsCache = new WeakMap();
1937
1937
  const LightningElement = function () {
1938
1938
  // This should be as performant as possible, while any initialization should be done lazily
1939
1939
  if (isNull(vmBeingConstructed)) {
1940
- throw new ReferenceError('Illegal constructor');
1940
+ // Thrown when doing something like `new LightningElement()` or
1941
+ // `class Foo extends LightningElement {}; new Foo()`
1942
+ throw new TypeError('Illegal constructor');
1941
1943
  }
1942
1944
  const vm = vmBeingConstructed;
1943
1945
  const { def, elm } = vm;
@@ -2986,274 +2988,213 @@ const swappedStyleMap = new WeakMap();
2986
2988
  const activeTemplates = new WeakMap();
2987
2989
  const activeComponents = new WeakMap();
2988
2990
  const activeStyles = new WeakMap();
2989
-
2990
2991
  function rehydrateHotTemplate(tpl) {
2991
- const list = activeTemplates.get(tpl);
2992
-
2993
- if (!isUndefined$1(list)) {
2994
- list.forEach(vm => {
2995
- if (isFalse(vm.isDirty)) {
2996
- // forcing the vm to rehydrate in the micro-task:
2997
- markComponentAsDirty(vm);
2998
- scheduleRehydration(vm);
2999
- }
3000
- }); // resetting the Set to release the memory of those vm references
3001
- // since they are not longer related to this template, instead
3002
- // they will get re-associated once these instances are rehydrated.
3003
-
3004
- list.clear();
3005
- }
3006
-
3007
- return true;
2992
+ const list = activeTemplates.get(tpl);
2993
+ if (!isUndefined$1(list)) {
2994
+ list.forEach((vm) => {
2995
+ if (isFalse(vm.isDirty)) {
2996
+ // forcing the vm to rehydrate in the micro-task:
2997
+ markComponentAsDirty(vm);
2998
+ scheduleRehydration(vm);
2999
+ }
3000
+ });
3001
+ // resetting the Set to release the memory of those vm references
3002
+ // since they are not longer related to this template, instead
3003
+ // they will get re-associated once these instances are rehydrated.
3004
+ list.clear();
3005
+ }
3006
+ return true;
3008
3007
  }
3009
-
3010
3008
  function rehydrateHotStyle(style) {
3011
- const list = activeStyles.get(style);
3012
-
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
- }); // resetting the Set to release the memory of those vm references
3019
- // since they are not longer related to this style, instead
3020
- // they will get re-associated once these instances are rehydrated.
3021
-
3022
- list.clear();
3023
- }
3024
-
3025
- return true;
3009
+ const list = activeStyles.get(style);
3010
+ if (!isUndefined$1(list)) {
3011
+ list.forEach((vm) => {
3012
+ // if a style definition is swapped, we must reset
3013
+ // vm's template content in the next micro-task:
3014
+ forceRehydration(vm);
3015
+ });
3016
+ // resetting the Set to release the memory of those vm references
3017
+ // since they are not longer related to this style, instead
3018
+ // they will get re-associated once these instances are rehydrated.
3019
+ list.clear();
3020
+ }
3021
+ return true;
3026
3022
  }
3027
-
3028
3023
  function rehydrateHotComponent(Ctor) {
3029
- const list = activeComponents.get(Ctor);
3030
- let canRefreshAllInstances = true;
3031
-
3032
- if (!isUndefined$1(list)) {
3033
- list.forEach(vm => {
3034
- const {
3035
- owner
3036
- } = vm;
3037
-
3038
- if (!isNull(owner)) {
3039
- // if a component class definition is swapped, we must reset
3040
- // owner's template content in the next micro-task:
3041
- forceRehydration(owner);
3042
- } else {
3043
- // the hot swapping for components only work for instances of components
3044
- // created from a template, root elements can't be swapped because we
3045
- // don't have a way to force the creation of the element with the same state
3046
- // of the current element.
3047
- // Instead, we can report the problem to the caller so it can take action,
3048
- // for example: reload the entire page.
3049
- canRefreshAllInstances = false;
3050
- }
3051
- }); // resetting the Set to release the memory of those vm references
3052
- // since they are not longer related to this constructor, instead
3053
- // they will get re-associated once these instances are rehydrated.
3054
-
3055
- list.clear();
3056
- }
3057
-
3058
- return canRefreshAllInstances;
3024
+ const list = activeComponents.get(Ctor);
3025
+ let canRefreshAllInstances = true;
3026
+ if (!isUndefined$1(list)) {
3027
+ list.forEach((vm) => {
3028
+ const { owner } = vm;
3029
+ if (!isNull(owner)) {
3030
+ // if a component class definition is swapped, we must reset
3031
+ // owner's template content in the next micro-task:
3032
+ forceRehydration(owner);
3033
+ }
3034
+ else {
3035
+ // the hot swapping for components only work for instances of components
3036
+ // created from a template, root elements can't be swapped because we
3037
+ // don't have a way to force the creation of the element with the same state
3038
+ // of the current element.
3039
+ // Instead, we can report the problem to the caller so it can take action,
3040
+ // for example: reload the entire page.
3041
+ canRefreshAllInstances = false;
3042
+ }
3043
+ });
3044
+ // resetting the Set to release the memory of those vm references
3045
+ // since they are not longer related to this constructor, instead
3046
+ // they will get re-associated once these instances are rehydrated.
3047
+ list.clear();
3048
+ }
3049
+ return canRefreshAllInstances;
3059
3050
  }
3060
-
3061
3051
  function getTemplateOrSwappedTemplate(tpl) {
3062
- if (process.env.NODE_ENV === 'production') {
3063
- // this method should never leak to prod
3064
- throw new ReferenceError();
3065
- }
3066
-
3067
- if (lwcRuntimeFlags.ENABLE_HMR) {
3052
+ if (process.env.NODE_ENV === 'production') {
3053
+ // this method should never leak to prod
3054
+ throw new ReferenceError();
3055
+ }
3068
3056
  const visited = new Set();
3069
-
3070
3057
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
3071
- visited.add(tpl);
3072
- tpl = swappedTemplateMap.get(tpl);
3058
+ visited.add(tpl);
3059
+ tpl = swappedTemplateMap.get(tpl);
3073
3060
  }
3074
- }
3075
-
3076
- return tpl;
3061
+ return tpl;
3077
3062
  }
3078
3063
  function getComponentOrSwappedComponent(Ctor) {
3079
- if (process.env.NODE_ENV === 'production') {
3080
- // this method should never leak to prod
3081
- throw new ReferenceError();
3082
- }
3083
-
3084
- if (lwcRuntimeFlags.ENABLE_HMR) {
3064
+ if (process.env.NODE_ENV === 'production') {
3065
+ // this method should never leak to prod
3066
+ throw new ReferenceError();
3067
+ }
3085
3068
  const visited = new Set();
3086
-
3087
3069
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
3088
- visited.add(Ctor);
3089
- Ctor = swappedComponentMap.get(Ctor);
3070
+ visited.add(Ctor);
3071
+ Ctor = swappedComponentMap.get(Ctor);
3090
3072
  }
3091
- }
3092
-
3093
- return Ctor;
3073
+ return Ctor;
3094
3074
  }
3095
3075
  function getStyleOrSwappedStyle(style) {
3096
- if (process.env.NODE_ENV === 'production') {
3097
- // this method should never leak to prod
3098
- throw new ReferenceError();
3099
- }
3100
-
3101
- if (lwcRuntimeFlags.ENABLE_HMR) {
3076
+ if (process.env.NODE_ENV === 'production') {
3077
+ // this method should never leak to prod
3078
+ throw new ReferenceError();
3079
+ }
3102
3080
  const visited = new Set();
3103
-
3104
3081
  while (swappedStyleMap.has(style) && !visited.has(style)) {
3105
- visited.add(style);
3106
- style = swappedStyleMap.get(style);
3082
+ visited.add(style);
3083
+ style = swappedStyleMap.get(style);
3107
3084
  }
3108
- }
3109
-
3110
- return style;
3085
+ return style;
3111
3086
  }
3112
3087
  function setActiveVM(vm) {
3113
- if (process.env.NODE_ENV === 'production') {
3114
- // this method should never leak to prod
3115
- throw new ReferenceError();
3116
- }
3117
-
3118
- if (lwcRuntimeFlags.ENABLE_HMR) {
3088
+ if (process.env.NODE_ENV === 'production') {
3089
+ // this method should never leak to prod
3090
+ throw new ReferenceError();
3091
+ }
3119
3092
  // tracking active component
3120
3093
  const Ctor = vm.def.ctor;
3121
3094
  let componentVMs = activeComponents.get(Ctor);
3122
-
3123
3095
  if (isUndefined$1(componentVMs)) {
3124
- componentVMs = new Set();
3125
- activeComponents.set(Ctor, componentVMs);
3126
- } // this will allow us to keep track of the hot components
3127
-
3128
-
3129
- componentVMs.add(vm); // tracking active template
3130
-
3096
+ componentVMs = new Set();
3097
+ activeComponents.set(Ctor, componentVMs);
3098
+ }
3099
+ // this will allow us to keep track of the hot components
3100
+ componentVMs.add(vm);
3101
+ // tracking active template
3131
3102
  const tpl = vm.cmpTemplate;
3132
-
3133
3103
  if (tpl) {
3134
- let templateVMs = activeTemplates.get(tpl);
3135
-
3136
- if (isUndefined$1(templateVMs)) {
3137
- templateVMs = new Set();
3138
- activeTemplates.set(tpl, templateVMs);
3139
- } // this will allow us to keep track of the templates that are
3140
- // being used by a hot component
3141
-
3142
-
3143
- templateVMs.add(vm); // tracking active styles associated to template
3144
-
3145
- const stylesheets = tpl.stylesheets;
3146
-
3147
- if (!isUndefined$1(stylesheets)) {
3148
- flattenStylesheets(stylesheets).forEach(stylesheet => {
3149
- // this is necessary because we don't hold the list of styles
3150
- // in the vm, we only hold the selected (already swapped template)
3151
- // but the styles attached to the template might not be the actual
3152
- // active ones, but the swapped versions of those.
3153
- stylesheet = getStyleOrSwappedStyle(stylesheet);
3154
- let stylesheetVMs = activeStyles.get(stylesheet);
3155
-
3156
- if (isUndefined$1(stylesheetVMs)) {
3157
- stylesheetVMs = new Set();
3158
- activeStyles.set(stylesheet, stylesheetVMs);
3159
- } // this will allow us to keep track of the stylesheet that are
3160
- // being used by a hot component
3161
-
3162
-
3163
- stylesheetVMs.add(vm);
3164
- });
3165
- }
3104
+ let templateVMs = activeTemplates.get(tpl);
3105
+ if (isUndefined$1(templateVMs)) {
3106
+ templateVMs = new Set();
3107
+ activeTemplates.set(tpl, templateVMs);
3108
+ }
3109
+ // this will allow us to keep track of the templates that are
3110
+ // being used by a hot component
3111
+ templateVMs.add(vm);
3112
+ // tracking active styles associated to template
3113
+ const stylesheets = tpl.stylesheets;
3114
+ if (!isUndefined$1(stylesheets)) {
3115
+ flattenStylesheets(stylesheets).forEach((stylesheet) => {
3116
+ // this is necessary because we don't hold the list of styles
3117
+ // in the vm, we only hold the selected (already swapped template)
3118
+ // but the styles attached to the template might not be the actual
3119
+ // active ones, but the swapped versions of those.
3120
+ stylesheet = getStyleOrSwappedStyle(stylesheet);
3121
+ let stylesheetVMs = activeStyles.get(stylesheet);
3122
+ if (isUndefined$1(stylesheetVMs)) {
3123
+ stylesheetVMs = new Set();
3124
+ activeStyles.set(stylesheet, stylesheetVMs);
3125
+ }
3126
+ // this will allow us to keep track of the stylesheet that are
3127
+ // being used by a hot component
3128
+ stylesheetVMs.add(vm);
3129
+ });
3130
+ }
3166
3131
  }
3167
- }
3168
3132
  }
3169
3133
  function removeActiveVM(vm) {
3170
- if (process.env.NODE_ENV === 'production') {
3171
- // this method should never leak to prod
3172
- throw new ReferenceError();
3173
- }
3174
-
3175
- if (lwcRuntimeFlags.ENABLE_HMR) {
3134
+ if (process.env.NODE_ENV === 'production') {
3135
+ // this method should never leak to prod
3136
+ throw new ReferenceError();
3137
+ }
3176
3138
  // tracking inactive component
3177
3139
  const Ctor = vm.def.ctor;
3178
3140
  let list = activeComponents.get(Ctor);
3179
-
3180
3141
  if (!isUndefined$1(list)) {
3181
- // deleting the vm from the set to avoid leaking memory
3182
- list.delete(vm);
3183
- } // removing inactive template
3184
-
3185
-
3186
- const tpl = vm.cmpTemplate;
3187
-
3188
- if (tpl) {
3189
- list = activeTemplates.get(tpl);
3190
-
3191
- if (!isUndefined$1(list)) {
3192
3142
  // deleting the vm from the set to avoid leaking memory
3193
3143
  list.delete(vm);
3194
- } // removing active styles associated to template
3195
-
3196
-
3197
- const styles = tpl.stylesheets;
3198
-
3199
- if (!isUndefined$1(styles)) {
3200
- flattenStylesheets(styles).forEach(style => {
3201
- list = activeStyles.get(style);
3202
-
3203
- if (!isUndefined$1(list)) {
3144
+ }
3145
+ // removing inactive template
3146
+ const tpl = vm.cmpTemplate;
3147
+ if (tpl) {
3148
+ list = activeTemplates.get(tpl);
3149
+ if (!isUndefined$1(list)) {
3204
3150
  // deleting the vm from the set to avoid leaking memory
3205
3151
  list.delete(vm);
3206
- }
3207
- });
3208
- }
3152
+ }
3153
+ // removing active styles associated to template
3154
+ const styles = tpl.stylesheets;
3155
+ if (!isUndefined$1(styles)) {
3156
+ flattenStylesheets(styles).forEach((style) => {
3157
+ list = activeStyles.get(style);
3158
+ if (!isUndefined$1(list)) {
3159
+ // deleting the vm from the set to avoid leaking memory
3160
+ list.delete(vm);
3161
+ }
3162
+ });
3163
+ }
3209
3164
  }
3210
- }
3211
3165
  }
3212
3166
  function swapTemplate(oldTpl, newTpl) {
3213
- if (process.env.NODE_ENV !== 'production') {
3214
- if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
3215
- swappedTemplateMap.set(oldTpl, newTpl);
3216
- return rehydrateHotTemplate(oldTpl);
3217
- } else {
3218
- throw new TypeError(`Invalid Template`);
3167
+ if (process.env.NODE_ENV !== 'production') {
3168
+ if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
3169
+ swappedTemplateMap.set(oldTpl, newTpl);
3170
+ return rehydrateHotTemplate(oldTpl);
3171
+ }
3172
+ else {
3173
+ throw new TypeError(`Invalid Template`);
3174
+ }
3219
3175
  }
3220
- }
3221
-
3222
- if (!lwcRuntimeFlags.ENABLE_HMR) {
3223
- throw new Error('HMR is not enabled');
3224
- }
3225
-
3226
- return false;
3176
+ return false;
3227
3177
  }
3228
3178
  function swapComponent(oldComponent, newComponent) {
3229
- if (process.env.NODE_ENV !== 'production') {
3230
- if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
3231
- swappedComponentMap.set(oldComponent, newComponent);
3232
- return rehydrateHotComponent(oldComponent);
3233
- } else {
3234
- throw new TypeError(`Invalid Component`);
3179
+ if (process.env.NODE_ENV !== 'production') {
3180
+ if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
3181
+ swappedComponentMap.set(oldComponent, newComponent);
3182
+ return rehydrateHotComponent(oldComponent);
3183
+ }
3184
+ else {
3185
+ throw new TypeError(`Invalid Component`);
3186
+ }
3235
3187
  }
3236
- }
3237
-
3238
- if (!lwcRuntimeFlags.ENABLE_HMR) {
3239
- throw new Error('HMR is not enabled');
3240
- }
3241
-
3242
- return false;
3188
+ return false;
3243
3189
  }
3244
3190
  function swapStyle(oldStyle, newStyle) {
3245
- if (process.env.NODE_ENV !== 'production') {
3246
- // TODO [#1887]: once the support for registering styles is implemented
3247
- // we can add the validation of both styles around this block.
3248
- swappedStyleMap.set(oldStyle, newStyle);
3249
- return rehydrateHotStyle(oldStyle);
3250
- }
3251
-
3252
- if (!lwcRuntimeFlags.ENABLE_HMR) {
3253
- throw new Error('HMR is not enabled');
3254
- }
3255
-
3256
- return false;
3191
+ if (process.env.NODE_ENV !== 'production') {
3192
+ // TODO [#1887]: once the support for registering styles is implemented
3193
+ // we can add the validation of both styles around this block.
3194
+ swappedStyleMap.set(oldStyle, newStyle);
3195
+ return rehydrateHotStyle(oldStyle);
3196
+ }
3197
+ return false;
3257
3198
  }
3258
3199
 
3259
3200
  /*
@@ -3664,15 +3605,18 @@ function getScopeTokenClass(owner) {
3664
3605
  /**
3665
3606
  * This function returns the host style token for a custom element if it
3666
3607
  * exists. Otherwise it returns null.
3608
+ *
3609
+ * A host style token is applied to the component if scoped styles are used.
3667
3610
  */
3668
3611
 
3669
3612
  function getStylesheetTokenHost(vnode) {
3670
3613
  const {
3671
- template: {
3672
- stylesheetToken
3673
- }
3614
+ template
3674
3615
  } = getComponentInternalDef(vnode.ctor);
3675
- return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
3616
+ const {
3617
+ stylesheetToken
3618
+ } = template;
3619
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
3676
3620
  }
3677
3621
 
3678
3622
  function getNearestNativeShadowComponent(vm) {
@@ -3726,75 +3670,6 @@ function createStylesheet(vm, stylesheets) {
3726
3670
  return null;
3727
3671
  }
3728
3672
 
3729
- /*
3730
- * Copyright (c) 2020, salesforce.com, inc.
3731
- * All rights reserved.
3732
- * SPDX-License-Identifier: MIT
3733
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3734
- */
3735
-
3736
- function checkHasVM(elm) {
3737
- const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
3738
-
3739
- if (process.env.NODE_ENV !== 'production' && !hasVM) {
3740
- // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
3741
- // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
3742
- logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
3743
- }
3744
-
3745
- return hasVM;
3746
- }
3747
-
3748
- function getUpgradableConstructor(tagName, renderer) {
3749
- const {
3750
- getCustomElement,
3751
- HTMLElementExported: RendererHTMLElement,
3752
- defineCustomElement
3753
- } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
3754
- // produce only tags with lowercase letters
3755
- // But, for backwards compatibility, we will lower case the tagName
3756
-
3757
- tagName = tagName.toLowerCase();
3758
- let CE = getCustomElement(tagName);
3759
-
3760
- if (!isUndefined$1(CE)) {
3761
- return CE;
3762
- }
3763
- /**
3764
- * LWC Upgradable Element reference to an element that was created
3765
- * via the scoped registry mechanism, and that is ready to be upgraded.
3766
- */
3767
-
3768
-
3769
- CE = class LWCUpgradableElement extends RendererHTMLElement {
3770
- constructor(upgradeCallback) {
3771
- super();
3772
-
3773
- if (isFunction$1(upgradeCallback)) {
3774
- upgradeCallback(this); // nothing to do with the result for now
3775
- }
3776
- }
3777
-
3778
- };
3779
-
3780
- if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3781
- CE.prototype.connectedCallback = function () {
3782
- if (checkHasVM(this)) {
3783
- connectRootElement(this);
3784
- }
3785
- };
3786
-
3787
- CE.prototype.disconnectedCallback = function () {
3788
- if (checkHasVM(this)) {
3789
- disconnectRootElement(this);
3790
- }
3791
- };
3792
- }
3793
-
3794
- defineCustomElement(tagName, CE);
3795
- return CE;
3796
- }
3797
-
3798
3673
  /*
3799
3674
  * Copyright (c) 2018, salesforce.com, inc.
3800
3675
  * All rights reserved.
@@ -4308,7 +4183,9 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4308
4183
  sel,
4309
4184
  owner
4310
4185
  } = vnode;
4311
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
4186
+ const {
4187
+ createCustomElement
4188
+ } = renderer;
4312
4189
  /**
4313
4190
  * Note: if the upgradable constructor does not expect, or throw when we new it
4314
4191
  * with a callback as the first argument, we could implement a more advanced
@@ -4317,10 +4194,25 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4317
4194
  */
4318
4195
 
4319
4196
  let vm;
4320
- const elm = new UpgradableConstructor(elm => {
4197
+
4198
+ const upgradeCallback = elm => {
4321
4199
  // the custom element from the registry is expecting an upgrade callback
4322
4200
  vm = createViewModelHook(elm, vnode, renderer);
4323
- });
4201
+ };
4202
+
4203
+ const connectedCallback = elm => {
4204
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4205
+ connectRootElement(elm);
4206
+ }
4207
+ };
4208
+
4209
+ const disconnectedCallback = elm => {
4210
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4211
+ disconnectRootElement(elm);
4212
+ }
4213
+ };
4214
+
4215
+ const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
4324
4216
  vnode.elm = elm;
4325
4217
  vnode.vm = vm;
4326
4218
  linkNodeToShadow(elm, owner, renderer);
@@ -4328,8 +4220,6 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4328
4220
 
4329
4221
  if (vm) {
4330
4222
  allocateChildren(vnode, vm);
4331
- } else if (vnode.ctor !== UpgradableConstructor) {
4332
- throw new TypeError(`Incorrect Component Constructor`);
4333
4223
  }
4334
4224
 
4335
4225
  patchElementPropsAndAttrs$1(null, vnode, renderer);
@@ -7103,19 +6993,23 @@ function validateClassAttr(vnode, elm, renderer) {
7103
6993
  //
7104
6994
  // Consequently, hydration mismatches will occur if scoped CSS token classnames
7105
6995
  // are rendered during SSR. This needs to be accounted for when validating.
7106
- if (scopedToken) {
6996
+ if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
7107
6997
  if (!isUndefined$1(className)) {
7108
- className = isNull(stylesheetTokenHost)
7109
- ? `${scopedToken} ${className}`
7110
- : `${scopedToken} ${className} ${stylesheetTokenHost}`;
6998
+ // The order of the className should be scopedToken className stylesheetTokenHost
6999
+ const classTokens = [scopedToken, className, stylesheetTokenHost];
7000
+ const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
7001
+ className = ArrayJoin.call(classNames, ' ');
7111
7002
  }
7112
7003
  else if (!isUndefined$1(classMap)) {
7113
- classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {} : { [stylesheetTokenHost]: true }));
7004
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
7114
7005
  }
7115
7006
  else {
7116
- className = isNull(stylesheetTokenHost)
7117
- ? `${scopedToken}`
7118
- : `${scopedToken} ${stylesheetTokenHost}`;
7007
+ // The order of the className should be scopedToken stylesheetTokenHost
7008
+ const classTokens = [scopedToken, stylesheetTokenHost];
7009
+ const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
7010
+ if (classNames.length) {
7011
+ className = ArrayJoin.call(classNames, ' ');
7012
+ }
7119
7013
  }
7120
7014
  }
7121
7015
  let nodesAreCompatible = true;
@@ -7357,7 +7251,7 @@ function getComponentConstructor(elm) {
7357
7251
  }
7358
7252
  return ctor;
7359
7253
  }
7360
- /* version: 2.25.1 */
7254
+ /* version: 2.26.0 */
7361
7255
 
7362
7256
  /*
7363
7257
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7501,6 +7395,626 @@ function insertStylesheet(content, target) {
7501
7395
  }
7502
7396
  }
7503
7397
 
7398
+ /*
7399
+ * Copyright (c) 2020, salesforce.com, inc.
7400
+ * All rights reserved.
7401
+ * SPDX-License-Identifier: MIT
7402
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7403
+ */
7404
+ function isCustomElementRegistryAvailable() {
7405
+ if (typeof customElements === 'undefined') {
7406
+ return false;
7407
+ }
7408
+ try {
7409
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
7410
+ // _wrapNativeSuper()
7411
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
7412
+ // get wrapped by babel.
7413
+ const HTMLElementAlias = HTMLElement;
7414
+ // In case we use compat mode with a modern browser, the compat mode transformation
7415
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
7416
+ // which are not equipped to be initialized that way.
7417
+ class clazz extends HTMLElementAlias {
7418
+ }
7419
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
7420
+ new clazz();
7421
+ return true;
7422
+ }
7423
+ catch (_a) {
7424
+ return false;
7425
+ }
7426
+ }
7427
+ const hasCustomElements = isCustomElementRegistryAvailable();
7428
+
7429
+ /*
7430
+ * Copyright (c) 2018, salesforce.com, inc.
7431
+ * All rights reserved.
7432
+ * SPDX-License-Identifier: MIT
7433
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7434
+ */
7435
+ // Creates a custom element for compat (legacy) browser environments
7436
+ const createCustomElementCompat = (tagName, upgradeCallback) => {
7437
+ const elm = document.createElement(tagName);
7438
+ upgradeCallback(elm); // nothing to do with the result for now
7439
+ return elm;
7440
+ };
7441
+
7442
+ /*
7443
+ * Copyright (c) 2018, salesforce.com, inc.
7444
+ * All rights reserved.
7445
+ * SPDX-License-Identifier: MIT
7446
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7447
+ */
7448
+ const cachedConstructors = new Map();
7449
+ const elementsUpgradedOutsideLWC = new WeakSet();
7450
+ let elementBeingUpgradedByLWC = false;
7451
+ // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
7452
+ // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
7453
+ // Another benefit is that only LWC can create components that actually do anything – if you do
7454
+ // `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
7455
+ // This class should be created once per tag name.
7456
+ const createUpgradableConstructor = (connectedCallback, disconnectedCallback) => {
7457
+ // TODO [#2972]: this class should expose observedAttributes as necessary
7458
+ return class UpgradableConstructor extends HTMLElement {
7459
+ constructor(upgradeCallback) {
7460
+ super();
7461
+ // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
7462
+ // then elementBeingUpgraded will be false
7463
+ if (elementBeingUpgradedByLWC) {
7464
+ upgradeCallback(this);
7465
+ }
7466
+ else {
7467
+ // keep track of elements that were not created by lwc.createElement,
7468
+ // so we can ignore their lifecycle hooks
7469
+ elementsUpgradedOutsideLWC.add(this);
7470
+ // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
7471
+ // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
7472
+ }
7473
+ }
7474
+ connectedCallback() {
7475
+ if (!elementsUpgradedOutsideLWC.has(this)) {
7476
+ connectedCallback(this);
7477
+ }
7478
+ }
7479
+ disconnectedCallback() {
7480
+ if (!elementsUpgradedOutsideLWC.has(this)) {
7481
+ disconnectedCallback(this);
7482
+ }
7483
+ }
7484
+ };
7485
+ };
7486
+ const createCustomElementVanilla = (tagName, upgradeCallback, connectedCallback, disconnectedCallback) => {
7487
+ // use global custom elements registry
7488
+ let UpgradableConstructor = cachedConstructors.get(tagName);
7489
+ if (isUndefined$1(UpgradableConstructor)) {
7490
+ if (!isUndefined$1(customElements.get(tagName))) {
7491
+ throw new Error(`Unexpected tag name "${tagName}". This name is a registered custom element, preventing LWC to upgrade the element.`);
7492
+ }
7493
+ UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
7494
+ customElements.define(tagName, UpgradableConstructor);
7495
+ cachedConstructors.set(tagName, UpgradableConstructor);
7496
+ }
7497
+ elementBeingUpgradedByLWC = true;
7498
+ try {
7499
+ return new UpgradableConstructor(upgradeCallback);
7500
+ }
7501
+ finally {
7502
+ elementBeingUpgradedByLWC = false;
7503
+ }
7504
+ };
7505
+
7506
+ /*
7507
+ * Copyright (c) 2020, salesforce.com, inc.
7508
+ * All rights reserved.
7509
+ * SPDX-License-Identifier: MIT
7510
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7511
+ */
7512
+ /**
7513
+ * Create a scoped registry, i.e. a function that can create custom elements whose tag names
7514
+ * do not conflict with vanilla custom elements having the same tag name.
7515
+ */
7516
+ function createScopedRegistry() {
7517
+ if (!hasCustomElements) {
7518
+ // This code should never be reached, because we don't use the pivot registry if
7519
+ // custom elements are unavailable.
7520
+ throw new Error('Custom elements are not supported in this environment.');
7521
+ }
7522
+ const { HTMLElement: NativeHTMLElement } = window;
7523
+ const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
7524
+ const definitionForElement = new WeakMap();
7525
+ const pendingRegistryForElement = new WeakMap();
7526
+ const definitionForConstructor = new WeakMap();
7527
+ const registeredUserCtors = new WeakSet();
7528
+ const pivotCtorByTag = new Map();
7529
+ const globalDefinitionsByTag = new Map();
7530
+ const globalDefinitionsByClass = new Map();
7531
+ const awaitingUpgrade = new Map();
7532
+ const EMPTY_SET = new Set();
7533
+ function createDefinitionRecord(constructor) {
7534
+ var _a;
7535
+ const { connectedCallback, disconnectedCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
7536
+ const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
7537
+ return {
7538
+ UserCtor: constructor,
7539
+ PivotCtor: undefined,
7540
+ connectedCallback,
7541
+ disconnectedCallback,
7542
+ adoptedCallback,
7543
+ attributeChangedCallback,
7544
+ observedAttributes,
7545
+ };
7546
+ }
7547
+ // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
7548
+ // element. Note that the `registeredDefinition` represents the constructor that was used to register during
7549
+ // `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
7550
+ // constructor is invoked with another constructor.
7551
+ function createPivotingClass(tagName, registeredDefinition) {
7552
+ class PivotCtor extends NativeHTMLElement {
7553
+ constructor(UserCtor) {
7554
+ // This constructor can only be invoked by:
7555
+ // a) the browser instantiating an element from parsing or via document.createElement.
7556
+ // b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
7557
+ // b) new UserClass.
7558
+ // When LWC instantiates it, it will pass the upgrading definition as an argument
7559
+ // If the caller signals via UserCtor that this is in fact a controlled
7560
+ // definition, we use that one, otherwise fallback to the global
7561
+ // internal registry.
7562
+ super();
7563
+ const userCtorIsDefined = !isUndefined$1(UserCtor);
7564
+ if (userCtorIsDefined) {
7565
+ if (!isConstructor(UserCtor)) {
7566
+ throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
7567
+ }
7568
+ if (!registeredUserCtors.has(UserCtor)) {
7569
+ throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
7570
+ }
7571
+ }
7572
+ const definition = userCtorIsDefined
7573
+ ? getOrCreateDefinitionForConstructor(UserCtor)
7574
+ : globalDefinitionsByTag.get(tagName);
7575
+ if (!isUndefined$1(definition)) {
7576
+ internalUpgrade(this, registeredDefinition, definition);
7577
+ }
7578
+ else {
7579
+ // This is the case in which there is no global definition, and
7580
+ // it is not handled by LWC (otherwise it will have a valid UserCtor)
7581
+ // so we need to add it to the pending queue just in case it eventually
7582
+ // gets defined in the global registry.
7583
+ pendingRegistryForElement.set(this, registeredDefinition);
7584
+ }
7585
+ }
7586
+ connectedCallback() {
7587
+ var _a;
7588
+ const definition = definitionForElement.get(this);
7589
+ if (!isUndefined$1(definition)) {
7590
+ // Delegate out to user callback
7591
+ (_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
7592
+ }
7593
+ else {
7594
+ // Register for upgrade when defined (only when connected, so we don't leak)
7595
+ let awaiting = awaitingUpgrade.get(tagName);
7596
+ if (isUndefined$1(awaiting)) {
7597
+ awaitingUpgrade.set(tagName, (awaiting = new Set()));
7598
+ }
7599
+ awaiting.add(this);
7600
+ }
7601
+ }
7602
+ disconnectedCallback() {
7603
+ var _a;
7604
+ const definition = definitionForElement.get(this);
7605
+ if (!isUndefined$1(definition)) {
7606
+ // Delegate out to user callback
7607
+ (_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
7608
+ }
7609
+ else {
7610
+ // Un-register for upgrade when defined (so we don't leak)
7611
+ const awaiting = awaitingUpgrade.get(tagName);
7612
+ // At this point, awaiting should never be undefined, because connectedCallback
7613
+ // must have been called before disconnectedCallback. But just to be safe, we check
7614
+ if (!isUndefined$1(awaiting)) {
7615
+ awaiting.delete(this);
7616
+ }
7617
+ }
7618
+ }
7619
+ adoptedCallback() {
7620
+ var _a;
7621
+ const definition = definitionForElement.get(this);
7622
+ (_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
7623
+ }
7624
+ attributeChangedCallback(name, oldValue, newValue) {
7625
+ var _a;
7626
+ const definition = definitionForElement.get(this);
7627
+ // if both definitions are the same, then the observedAttributes is the same,
7628
+ // but if they are different, only if the runtime definition has the attribute
7629
+ // marked as observed, then it should invoke attributeChangedCallback.
7630
+ if (registeredDefinition === definition ||
7631
+ (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
7632
+ (_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
7633
+ }
7634
+ }
7635
+ }
7636
+ PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
7637
+ return PivotCtor;
7638
+ }
7639
+ function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
7640
+ const { observedAttributes, attributeChangedCallback } = pivotDefinition;
7641
+ if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
7642
+ // This instance does not need to observe any attributes, no need to patch
7643
+ return EMPTY_SET;
7644
+ }
7645
+ // Natively, the attributes observed by the registered definition are going to be taken
7646
+ // care of by the browser, only the difference between the two sets has to be taken
7647
+ // care by the patched version.
7648
+ return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
7649
+ }
7650
+ function throwAsyncError(error) {
7651
+ // Per native custom element behavior, errors thrown in attributeChangedCallback
7652
+ // become unhandled async errors. We use setTimeout() instead of Promise.resolve()
7653
+ // to make it an unhandled error rather than an unhandled rejection.
7654
+ setTimeout(() => {
7655
+ throw error;
7656
+ });
7657
+ }
7658
+ // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
7659
+ // Why is this necessary? Well basically, you can't change the `observedAttributes` after
7660
+ // a custom element is defined. So with pivots, if two classes share the same tag name,
7661
+ // and the second class observes attributes that aren't observed by the first one,
7662
+ // then those attributes can never be observed by the native `observedAttributes` system.
7663
+ // So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
7664
+ // we only do this when absolutely necessary, though; i.e. because we've determined
7665
+ // that we aren't observing the attributes we need to.
7666
+ function patchAttributes(instance, registeredDefinition, pivotDefinition) {
7667
+ const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
7668
+ if (newObservedAttributes.size === 0) {
7669
+ return;
7670
+ }
7671
+ const { attributeChangedCallback } = pivotDefinition;
7672
+ // Patch the instance.
7673
+ // Note we use the native `getAttribute` rather than the super's `getAttribute` because
7674
+ // we don't actually want it to be observable that we're calling `getAttribute` from
7675
+ // `setAttribute` and `removeAttribute`.
7676
+ // TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
7677
+ defineProperties(instance, {
7678
+ setAttribute: {
7679
+ value: function setAttribute(name, value) {
7680
+ if (newObservedAttributes.has(name)) {
7681
+ const old = nativeGetAttribute.call(this, name);
7682
+ nativeSetAttribute.call(this, name, value);
7683
+ try {
7684
+ attributeChangedCallback.call(this, name, old, value + '');
7685
+ }
7686
+ catch (error) {
7687
+ throwAsyncError(error);
7688
+ }
7689
+ }
7690
+ else {
7691
+ nativeSetAttribute.call(this, name, value);
7692
+ }
7693
+ },
7694
+ writable: true,
7695
+ enumerable: true,
7696
+ configurable: true,
7697
+ },
7698
+ removeAttribute: {
7699
+ value: function removeAttribute(name) {
7700
+ if (newObservedAttributes.has(name)) {
7701
+ const old = nativeGetAttribute.call(this, name);
7702
+ nativeRemoveAttribute.call(this, name);
7703
+ try {
7704
+ attributeChangedCallback.call(this, name, old, null);
7705
+ }
7706
+ catch (error) {
7707
+ throwAsyncError(error);
7708
+ }
7709
+ }
7710
+ else {
7711
+ nativeRemoveAttribute.call(this, name);
7712
+ }
7713
+ },
7714
+ writable: true,
7715
+ enumerable: true,
7716
+ configurable: true,
7717
+ },
7718
+ });
7719
+ }
7720
+ function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
7721
+ // The below case patches observed attributes for the case where the HTML element is upgraded
7722
+ // from a pre-existing one in the DOM.
7723
+ const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
7724
+ if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
7725
+ return;
7726
+ }
7727
+ const { attributeChangedCallback } = pivotDefinition;
7728
+ // Approximate observedAttributes from the user class, but only for the new observed attributes
7729
+ newObservedAttributes.forEach((name) => {
7730
+ if (nativeHasAttribute.call(instance, name)) {
7731
+ const newValue = nativeGetAttribute.call(instance, name);
7732
+ attributeChangedCallback.call(instance, name, null, newValue);
7733
+ }
7734
+ });
7735
+ }
7736
+ // User extends this HTMLElement, which returns the CE being upgraded
7737
+ let upgradingInstance;
7738
+ // Helper to upgrade an instance with a CE definition using "constructor call trick"
7739
+ function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
7740
+ setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
7741
+ definitionForElement.set(instance, pivotDefinition);
7742
+ // attributes patches when needed
7743
+ if (pivotDefinition !== registeredDefinition) {
7744
+ patchAttributes(instance, registeredDefinition, pivotDefinition);
7745
+ }
7746
+ // Tricking the construction path to believe that a new instance is being created,
7747
+ // that way it will execute the super initialization mechanism but the HTMLElement
7748
+ // constructor will reuse the instance by returning the upgradingInstance.
7749
+ // This is by far the most important piece of the puzzle
7750
+ upgradingInstance = instance;
7751
+ // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
7752
+ // The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
7753
+ // Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
7754
+ new pivotDefinition.UserCtor();
7755
+ patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
7756
+ }
7757
+ function isConstructor(constructor) {
7758
+ return isFunction$1(constructor) && isObject(constructor.prototype);
7759
+ }
7760
+ function getOrCreateDefinitionForConstructor(constructor) {
7761
+ if (!isConstructor(constructor)) {
7762
+ throw new TypeError('The referenced constructor is not a constructor.');
7763
+ }
7764
+ const definition = definitionForConstructor.get(constructor);
7765
+ if (!isUndefined$1(definition)) {
7766
+ return definition;
7767
+ }
7768
+ return createDefinitionRecord(constructor);
7769
+ }
7770
+ const { customElements: nativeRegistry } = window;
7771
+ const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
7772
+ // patch for the global registry define mechanism
7773
+ CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
7774
+ if (options && options.extends) {
7775
+ // TODO [#2983]: should we support `extends`?
7776
+ throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
7777
+ }
7778
+ if (globalDefinitionsByTag.has(tagName)) {
7779
+ throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
7780
+ }
7781
+ if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
7782
+ throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
7783
+ }
7784
+ const definition = getOrCreateDefinitionForConstructor(constructor);
7785
+ registeredUserCtors.add(constructor);
7786
+ let PivotCtor = pivotCtorByTag.get(tagName);
7787
+ if (isUndefined$1(PivotCtor)) {
7788
+ PivotCtor = createPivotingClass(tagName, definition);
7789
+ // Register a pivoting class which will handle global registry initializations
7790
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
7791
+ }
7792
+ // Only cache after nativeDefine has been called, because if it throws an error
7793
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
7794
+ definitionForConstructor.set(constructor, definition);
7795
+ pivotCtorByTag.set(tagName, PivotCtor);
7796
+ globalDefinitionsByTag.set(tagName, definition);
7797
+ globalDefinitionsByClass.set(constructor, definition);
7798
+ // For globally defined custom elements, the definition associated
7799
+ // to the UserCtor has a back-pointer to PivotCtor in case the user
7800
+ // new the UserCtor, so we know how to create the underlying element.
7801
+ definition.PivotCtor = PivotCtor;
7802
+ // Upgrade any elements created in this scope before customElements.define
7803
+ // was called, which should be exhibited by the following steps:
7804
+ // 1) LWC registers a tagName for an LWC component.
7805
+ // 2) Element with same tagName is created with document.createElement()
7806
+ // and inserted into DOM.
7807
+ // 3) customElements.define() is called with tagName and non-LWC constructor.
7808
+ // This requires immediate upgrade when the new global tagName is defined.
7809
+ const awaiting = awaitingUpgrade.get(tagName);
7810
+ if (!isUndefined$1(awaiting)) {
7811
+ awaitingUpgrade.delete(tagName);
7812
+ for (const element of awaiting) {
7813
+ const registeredDefinition = pendingRegistryForElement.get(element);
7814
+ // At this point, registeredDefinition should never be undefined because awaitingUpgrade
7815
+ // is only populated when we haven't run internalUpgrade yet, and we only populate
7816
+ // pendingRegistryForElement when internalUpgrade hasn't run yet.
7817
+ // But just to be safe, we check.
7818
+ if (!isUndefined$1(registeredDefinition)) {
7819
+ pendingRegistryForElement.delete(element);
7820
+ internalUpgrade(element, registeredDefinition, definition);
7821
+ }
7822
+ }
7823
+ }
7824
+ };
7825
+ CustomElementRegistry.prototype.get = function get(tagName) {
7826
+ const NativeCtor = nativeGet.call(nativeRegistry, tagName);
7827
+ if (!isUndefined$1(NativeCtor)) {
7828
+ const definition = globalDefinitionsByTag.get(tagName);
7829
+ if (!isUndefined$1(definition)) {
7830
+ return definition.UserCtor; // defined by the patched custom elements registry
7831
+ }
7832
+ // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7833
+ return NativeCtor; // return the pivot constructor or constructor that existed before patching
7834
+ }
7835
+ };
7836
+ CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
7837
+ return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
7838
+ const definition = globalDefinitionsByTag.get(tagName);
7839
+ if (!isUndefined$1(definition)) {
7840
+ return definition.UserCtor;
7841
+ }
7842
+ // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7843
+ // In this case, the custom element must have been defined before the registry patches
7844
+ // were applied. So return the non-pivot constructor
7845
+ if (isUndefined$1(NativeCtor)) {
7846
+ // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7847
+ // We can patch the correct behavior using customElements.get()
7848
+ return nativeGet.call(nativeRegistry, tagName);
7849
+ }
7850
+ return NativeCtor;
7851
+ });
7852
+ };
7853
+ // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
7854
+ // @ts-ignore
7855
+ window.HTMLElement = function HTMLElement() {
7856
+ // Upgrading case: the pivoting class constructor was run by the browser's
7857
+ // native custom elements and we're in the process of running the
7858
+ // "constructor-call trick" on the natively constructed instance, so just
7859
+ // return that here.
7860
+ // This code path is also called when LWC `new`s a PivotCtor.
7861
+ const instance = upgradingInstance;
7862
+ if (!isUndefined$1(instance)) {
7863
+ upgradingInstance = undefined;
7864
+ return instance;
7865
+ }
7866
+ // Construction case: we need to construct the pivoting instance and return it.
7867
+ // This is possible when the user register it via global registry and instantiate
7868
+ // it via `new Ctor()`.
7869
+ const { constructor } = this;
7870
+ const definition = globalDefinitionsByClass.get(constructor);
7871
+ if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
7872
+ // This code path is hit if someone `new`s a class that extends `HTMLElement` without
7873
+ // doing `customElements.define()` first. This matches native browser behavior:
7874
+ // https://stackoverflow.com/a/61883392
7875
+ throw new TypeError('Illegal constructor');
7876
+ }
7877
+ // This constructor is ONLY invoked when it is the user instantiating
7878
+ // an element via new Ctor while Ctor is a registered global constructor.
7879
+ const { PivotCtor, UserCtor } = definition;
7880
+ return new PivotCtor(UserCtor);
7881
+ };
7882
+ HTMLElement.prototype = NativeHTMLElement.prototype;
7883
+ /**
7884
+ * Create a new PivotConstructor for the given tagName, which is capable of being constructed
7885
+ * with a UserConstructor defining the behavior. Passing in the UserConstructor here
7886
+ * is a hint that can be used when registering a custom element with the global custom elements
7887
+ * registry for the first time, which provides certain optimizations. It also marks the UserConstructor
7888
+ * as "safe" to be used when passed in to a PivotConstructor.
7889
+ *
7890
+ * @param tagName - element tag name
7891
+ * @param UserCtor - userland custom element constructor
7892
+ * @returns a new custom element constructor
7893
+ */
7894
+ return function createPivotConstructor(tagName, UserCtor) {
7895
+ tagName = StringToLowerCase.call(tagName);
7896
+ let PivotCtor = pivotCtorByTag.get(tagName);
7897
+ if (isUndefined$1(PivotCtor)) {
7898
+ const definition = getOrCreateDefinitionForConstructor(UserCtor);
7899
+ PivotCtor = createPivotingClass(tagName, definition);
7900
+ // Register a pivoting class as a global custom element
7901
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
7902
+ definition.PivotCtor = PivotCtor;
7903
+ // Only cache after nativeDefine has been called, because if it throws an error
7904
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
7905
+ definitionForConstructor.set(UserCtor, definition);
7906
+ pivotCtorByTag.set(tagName, PivotCtor);
7907
+ }
7908
+ // Register a UserConstructor as "safe" to be used within a PivotConstructor
7909
+ registeredUserCtors.add(UserCtor);
7910
+ return PivotCtor;
7911
+ };
7912
+ }
7913
+
7914
+ /*
7915
+ * Copyright (c) 2018, salesforce.com, inc.
7916
+ * All rights reserved.
7917
+ * SPDX-License-Identifier: MIT
7918
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7919
+ */
7920
+ let createScopedConstructor;
7921
+ let CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
7922
+ // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
7923
+ // or we're in a legacy browser.
7924
+
7925
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
7926
+ if (hasCustomElements) {
7927
+ // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
7928
+ // It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
7929
+ //
7930
+ // Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
7931
+ //
7932
+ // 1. LWC loads
7933
+ // 2. `const Ctor = class extends HTMLElement {}`
7934
+ // 3. `lwc.createElement(...)` // here we lazily patch
7935
+ // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
7936
+ //
7937
+ // To reduce the risk of this, it's safer to patch the registry eagerly.
7938
+ createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
7939
+ // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
7940
+ // because the HTMLElement prototypes are mixed up.
7941
+ //
7942
+ // The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
7943
+ // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
7944
+ // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
7945
+ // Caching avoids this problem.
7946
+
7947
+ CachedHTMLElement = window.HTMLElement;
7948
+ }
7949
+ } // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
7950
+ // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
7951
+ // multiple times per tag name.
7952
+
7953
+
7954
+ const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
7955
+ // TODO [#2972]: this class should expose observedAttributes as necessary
7956
+ return class UserConstructor extends HTMLElementToExtend {
7957
+ constructor() {
7958
+ super();
7959
+ upgradeCallback(this);
7960
+ }
7961
+
7962
+ connectedCallback() {
7963
+ connectedCallback(this);
7964
+ }
7965
+
7966
+ disconnectedCallback() {
7967
+ disconnectedCallback(this);
7968
+ }
7969
+
7970
+ };
7971
+ };
7972
+
7973
+ function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
7974
+ if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
7975
+ // This error should be impossible to hit
7976
+ throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
7977
+ }
7978
+
7979
+ const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
7980
+ const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
7981
+ return new ScopedConstructor(UserConstructor);
7982
+ }
7983
+
7984
+ /*
7985
+ * Copyright (c) 2018, salesforce.com, inc.
7986
+ * All rights reserved.
7987
+ * SPDX-License-Identifier: MIT
7988
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7989
+ */
7990
+ /**
7991
+ * We have three modes for creating custom elements:
7992
+ *
7993
+ * 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
7994
+ * 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
7995
+ * same tag name, via a simple trick: every custom element constructor we define in the registry is basically
7996
+ * the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
7997
+ * constructor, which allows us to have completely customized functionality for different components.
7998
+ * 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
7999
+ * elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
8000
+ * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
8001
+ * because it must patch the global `customElements` and `HTMLElement` objects.
8002
+ */
8003
+
8004
+ let createCustomElement;
8005
+
8006
+ if (hasCustomElements) {
8007
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
8008
+ createCustomElement = createCustomElementScoped;
8009
+ } else {
8010
+ // use global custom elements registry (vanilla)
8011
+ createCustomElement = createCustomElementVanilla;
8012
+ }
8013
+ } else {
8014
+ // no registry available here
8015
+ createCustomElement = createCustomElementCompat;
8016
+ }
8017
+
7504
8018
  /*
7505
8019
  * Copyright (c) 2018, salesforce.com, inc.
7506
8020
  * All rights reserved.
@@ -7561,7 +8075,7 @@ function rendererFactory(baseRenderer) {
7561
8075
  function isNull(obj) {
7562
8076
  return obj === null;
7563
8077
  }
7564
- /** version: 2.25.1 */
8078
+ /** version: 2.26.0 */
7565
8079
 
7566
8080
  /*
7567
8081
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7569,65 +8083,6 @@ function rendererFactory(baseRenderer) {
7569
8083
  * SPDX-License-Identifier: MIT
7570
8084
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7571
8085
  */
7572
- exports.getCustomElement = void 0;
7573
- exports.defineCustomElement = void 0;
7574
- let HTMLElementConstructor;
7575
- function isCustomElementRegistryAvailable() {
7576
- if (typeof customElements === 'undefined') {
7577
- return false;
7578
- }
7579
- try {
7580
- // dereference HTMLElement global because babel wraps globals in compat mode with a
7581
- // _wrapNativeSuper()
7582
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
7583
- // get wrapped by babel.
7584
- const HTMLElementAlias = HTMLElement;
7585
- // In case we use compat mode with a modern browser, the compat mode transformation
7586
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
7587
- // which are not equipped to be initialized that way.
7588
- class clazz extends HTMLElementAlias {
7589
- }
7590
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
7591
- new clazz();
7592
- return true;
7593
- }
7594
- catch (_a) {
7595
- return false;
7596
- }
7597
- }
7598
- if (isCustomElementRegistryAvailable()) {
7599
- exports.getCustomElement = customElements.get.bind(customElements);
7600
- exports.defineCustomElement = customElements.define.bind(customElements);
7601
- HTMLElementConstructor = HTMLElement;
7602
- }
7603
- else {
7604
- const registry = Object.create(null);
7605
- const reverseRegistry = new WeakMap();
7606
- exports.defineCustomElement = function define(name, ctor) {
7607
- if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
7608
- throw new TypeError(`Invalid Registration`);
7609
- }
7610
- registry[name] = ctor;
7611
- reverseRegistry.set(ctor, name);
7612
- };
7613
- exports.getCustomElement = function get(name) {
7614
- return registry[name];
7615
- };
7616
- HTMLElementConstructor = function HTMLElement() {
7617
- if (!(this instanceof HTMLElement)) {
7618
- throw new TypeError(`Invalid Invocation`);
7619
- }
7620
- const { constructor } = this;
7621
- const name = reverseRegistry.get(constructor);
7622
- if (!name) {
7623
- throw new TypeError(`Invalid Construction`);
7624
- }
7625
- const elm = document.createElement(name);
7626
- Object.setPrototypeOf(elm, constructor.prototype);
7627
- return elm;
7628
- };
7629
- HTMLElementConstructor.prototype = HTMLElement.prototype;
7630
- }
7631
8086
  function cloneNode(node, deep) {
7632
8087
  return node.cloneNode(deep);
7633
8088
  }
@@ -7801,9 +8256,7 @@ function rendererFactory(baseRenderer) {
7801
8256
  function assertInstanceOfHTMLElement(elm, msg) {
7802
8257
  assert.invariant(elm instanceof HTMLElement, msg);
7803
8258
  }
7804
- const HTMLElementExported = HTMLElementConstructor;
7805
8259
 
7806
- exports.HTMLElementExported = HTMLElementExported;
7807
8260
  exports.addEventListener = addEventListener;
7808
8261
  exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
7809
8262
  exports.attachShadow = attachShadow;
@@ -7863,6 +8316,8 @@ rendererFactory(null),
7863
8316
  {
7864
8317
  // insertStyleSheet implementation shares a global cache of stylesheet data
7865
8318
  insertStylesheet,
8319
+ // relies on a shared global cache
8320
+ createCustomElement,
7866
8321
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7867
8322
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7868
8323
  });
@@ -7963,36 +8418,44 @@ function deprecatedBuildCustomElementConstructor(Ctor) {
7963
8418
  // This WeakSet usage is valid because this functionality is not meant to run in IE11.
7964
8419
  const hydratedCustomElements = new WeakSet();
7965
8420
  function buildCustomElementConstructor(Ctor) {
8421
+ var _a;
7966
8422
  const HtmlPrototype = getComponentHtmlPrototype(Ctor);
7967
- return class extends HtmlPrototype {
7968
- constructor() {
7969
- super();
7970
- if (this.isConnected) {
7971
- // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
7972
- hydrateComponent(this, Ctor, {});
7973
- hydratedCustomElements.add(this);
8423
+ const { observedAttributes } = HtmlPrototype;
8424
+ const { attributeChangedCallback } = HtmlPrototype.prototype;
8425
+ return _a = class extends HTMLElement {
8426
+ constructor() {
8427
+ super();
8428
+ if (this.isConnected) {
8429
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8430
+ hydrateComponent(this, Ctor, {});
8431
+ hydratedCustomElements.add(this);
8432
+ }
8433
+ else {
8434
+ createVM(this, Ctor, renderer, {
8435
+ mode: 'open',
8436
+ owner: null,
8437
+ tagName: this.tagName,
8438
+ });
8439
+ }
7974
8440
  }
7975
- else {
7976
- createVM(this, Ctor, renderer, {
7977
- mode: 'open',
7978
- owner: null,
7979
- tagName: this.tagName,
7980
- });
8441
+ connectedCallback() {
8442
+ if (hydratedCustomElements.has(this)) {
8443
+ // This is an un-upgraded element that was hydrated in the constructor.
8444
+ hydratedCustomElements.delete(this);
8445
+ }
8446
+ else {
8447
+ connectRootElement(this);
8448
+ }
7981
8449
  }
7982
- }
7983
- connectedCallback() {
7984
- if (hydratedCustomElements.has(this)) {
7985
- // This is an un-upgraded element that was hydrated in the constructor.
7986
- hydratedCustomElements.delete(this);
8450
+ disconnectedCallback() {
8451
+ disconnectRootElement(this);
7987
8452
  }
7988
- else {
7989
- connectRootElement(this);
8453
+ attributeChangedCallback(name, oldValue, newValue) {
8454
+ attributeChangedCallback.call(this, name, oldValue, newValue);
7990
8455
  }
7991
- }
7992
- disconnectedCallback() {
7993
- disconnectRootElement(this);
7994
- }
7995
- };
8456
+ },
8457
+ _a.observedAttributes = observedAttributes,
8458
+ _a;
7996
8459
  }
7997
8460
 
7998
8461
  /*
@@ -8079,8 +8542,13 @@ function createElement(sel, options) {
8079
8542
  throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
8080
8543
  }
8081
8544
 
8082
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
8083
- let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
8545
+ const {
8546
+ createCustomElement
8547
+ } = renderer; // tagName must be all lowercase, unfortunately, we have legacy code that is
8548
+ // passing `sel` as a camel-case, which makes them invalid custom elements name
8549
+ // the following line guarantees that this does not leaks beyond this point.
8550
+
8551
+ const tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
8084
8552
 
8085
8553
  /**
8086
8554
  * Note: if the upgradable constructor does not expect, or throw when we new it
@@ -8089,9 +8557,9 @@ function createElement(sel, options) {
8089
8557
  * an upgradable custom element.
8090
8558
  */
8091
8559
 
8092
- const element = new UpgradableConstructor(elm => {
8560
+ const upgradeCallback = elm => {
8093
8561
  createVM(elm, Ctor, renderer, {
8094
- tagName: sel,
8562
+ tagName,
8095
8563
  mode: options.mode !== 'closed' ? 'open' : 'closed',
8096
8564
  owner: null
8097
8565
  });
@@ -8100,15 +8568,21 @@ function createElement(sel, options) {
8100
8568
  ConnectingSlot.set(elm, connectRootElement);
8101
8569
  DisconnectingSlot.set(elm, disconnectRootElement);
8102
8570
  }
8571
+ };
8103
8572
 
8104
- wasComponentUpgraded = true;
8105
- });
8573
+ const connectedCallback = elm => {
8574
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8575
+ connectRootElement(elm);
8576
+ }
8577
+ };
8106
8578
 
8107
- if (!wasComponentUpgraded) {
8108
- /* eslint-disable-next-line no-console */
8109
- console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
8110
- }
8579
+ const disconnectedCallback = elm => {
8580
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8581
+ disconnectRootElement(elm);
8582
+ }
8583
+ };
8111
8584
 
8585
+ const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
8112
8586
  return element;
8113
8587
  }
8114
8588
 
@@ -8180,6 +8654,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
8180
8654
  });
8181
8655
  freeze(LightningElement);
8182
8656
  seal(LightningElement.prototype);
8183
- /* version: 2.25.1 */
8657
+ /* version: 2.26.0 */
8184
8658
 
8185
8659
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };