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