lwc 2.25.1 → 2.26.1

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