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
@@ -294,7 +294,7 @@
294
294
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
295
295
  return attributeName;
296
296
  }
297
- /** version: 2.25.1 */
297
+ /** version: 2.26.0 */
298
298
 
299
299
  /**
300
300
  * Copyright (C) 2018 salesforce.com, inc.
@@ -376,7 +376,7 @@
376
376
  patch$1(propName);
377
377
  }
378
378
  }
379
- /** version: 2.25.1 */
379
+ /** version: 2.26.0 */
380
380
 
381
381
  /**
382
382
  * Copyright (C) 2018 salesforce.com, inc.
@@ -392,7 +392,6 @@
392
392
  DUMMY_TEST_FLAG: null,
393
393
  ENABLE_ELEMENT_PATCH: null,
394
394
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
395
- ENABLE_HMR: null,
396
395
  ENABLE_HTML_COLLECTIONS_PATCH: null,
397
396
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
398
397
  ENABLE_MIXED_SHADOW_MODE: null,
@@ -403,6 +402,7 @@
403
402
  ENABLE_WIRE_SYNC_EMIT: null,
404
403
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
405
404
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
405
+ ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
406
406
  };
407
407
  if (!_globalThis.lwcRuntimeFlags) {
408
408
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -1387,7 +1387,9 @@
1387
1387
  const LightningElement = function () {
1388
1388
  // This should be as performant as possible, while any initialization should be done lazily
1389
1389
  if (isNull(vmBeingConstructed)) {
1390
- throw new ReferenceError('Illegal constructor');
1390
+ // Thrown when doing something like `new LightningElement()` or
1391
+ // `class Foo extends LightningElement {}; new Foo()`
1392
+ throw new TypeError('Illegal constructor');
1391
1393
  }
1392
1394
  const vm = vmBeingConstructed;
1393
1395
  const { def, elm } = vm;
@@ -2167,34 +2169,19 @@
2167
2169
  freeze(BaseBridgeElement);
2168
2170
  seal(BaseBridgeElement.prototype);
2169
2171
  function setActiveVM(vm) {
2170
- {
2171
- // this method should never leak to prod
2172
- throw new ReferenceError();
2173
- }
2172
+ {
2173
+ // this method should never leak to prod
2174
+ throw new ReferenceError();
2175
+ }
2174
2176
  }
2175
2177
  function swapTemplate(oldTpl, newTpl) {
2176
-
2177
- if (!lwcRuntimeFlags.ENABLE_HMR) {
2178
- throw new Error('HMR is not enabled');
2179
- }
2180
-
2181
- return false;
2178
+ return false;
2182
2179
  }
2183
2180
  function swapComponent(oldComponent, newComponent) {
2184
-
2185
- if (!lwcRuntimeFlags.ENABLE_HMR) {
2186
- throw new Error('HMR is not enabled');
2187
- }
2188
-
2189
- return false;
2181
+ return false;
2190
2182
  }
2191
2183
  function swapStyle(oldStyle, newStyle) {
2192
-
2193
- if (!lwcRuntimeFlags.ENABLE_HMR) {
2194
- throw new Error('HMR is not enabled');
2195
- }
2196
-
2197
- return false;
2184
+ return false;
2198
2185
  }
2199
2186
 
2200
2187
  /*
@@ -2573,15 +2560,18 @@
2573
2560
  /**
2574
2561
  * This function returns the host style token for a custom element if it
2575
2562
  * exists. Otherwise it returns null.
2563
+ *
2564
+ * A host style token is applied to the component if scoped styles are used.
2576
2565
  */
2577
2566
 
2578
2567
  function getStylesheetTokenHost(vnode) {
2579
2568
  const {
2580
- template: {
2581
- stylesheetToken
2582
- }
2569
+ template
2583
2570
  } = getComponentInternalDef(vnode.ctor);
2584
- return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
2571
+ const {
2572
+ stylesheetToken
2573
+ } = template;
2574
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
2585
2575
  }
2586
2576
 
2587
2577
  function getNearestNativeShadowComponent(vm) {
@@ -2635,69 +2625,6 @@
2635
2625
  return null;
2636
2626
  }
2637
2627
 
2638
- /*
2639
- * Copyright (c) 2020, salesforce.com, inc.
2640
- * All rights reserved.
2641
- * SPDX-License-Identifier: MIT
2642
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2643
- */
2644
-
2645
- function checkHasVM(elm) {
2646
- const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
2647
-
2648
- return hasVM;
2649
- }
2650
-
2651
- function getUpgradableConstructor(tagName, renderer) {
2652
- const {
2653
- getCustomElement,
2654
- HTMLElementExported: RendererHTMLElement,
2655
- defineCustomElement
2656
- } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
2657
- // produce only tags with lowercase letters
2658
- // But, for backwards compatibility, we will lower case the tagName
2659
-
2660
- tagName = tagName.toLowerCase();
2661
- let CE = getCustomElement(tagName);
2662
-
2663
- if (!isUndefined$1(CE)) {
2664
- return CE;
2665
- }
2666
- /**
2667
- * LWC Upgradable Element reference to an element that was created
2668
- * via the scoped registry mechanism, and that is ready to be upgraded.
2669
- */
2670
-
2671
-
2672
- CE = class LWCUpgradableElement extends RendererHTMLElement {
2673
- constructor(upgradeCallback) {
2674
- super();
2675
-
2676
- if (isFunction$1(upgradeCallback)) {
2677
- upgradeCallback(this); // nothing to do with the result for now
2678
- }
2679
- }
2680
-
2681
- };
2682
-
2683
- if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
2684
- CE.prototype.connectedCallback = function () {
2685
- if (checkHasVM(this)) {
2686
- connectRootElement(this);
2687
- }
2688
- };
2689
-
2690
- CE.prototype.disconnectedCallback = function () {
2691
- if (checkHasVM(this)) {
2692
- disconnectRootElement(this);
2693
- }
2694
- };
2695
- }
2696
-
2697
- defineCustomElement(tagName, CE);
2698
- return CE;
2699
- }
2700
-
2701
2628
  /*
2702
2629
  * Copyright (c) 2018, salesforce.com, inc.
2703
2630
  * All rights reserved.
@@ -3185,7 +3112,9 @@
3185
3112
  sel,
3186
3113
  owner
3187
3114
  } = vnode;
3188
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3115
+ const {
3116
+ createCustomElement
3117
+ } = renderer;
3189
3118
  /**
3190
3119
  * Note: if the upgradable constructor does not expect, or throw when we new it
3191
3120
  * with a callback as the first argument, we could implement a more advanced
@@ -3194,10 +3123,25 @@
3194
3123
  */
3195
3124
 
3196
3125
  let vm;
3197
- const elm = new UpgradableConstructor(elm => {
3126
+
3127
+ const upgradeCallback = elm => {
3198
3128
  // the custom element from the registry is expecting an upgrade callback
3199
3129
  vm = createViewModelHook(elm, vnode, renderer);
3200
- });
3130
+ };
3131
+
3132
+ const connectedCallback = elm => {
3133
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3134
+ connectRootElement(elm);
3135
+ }
3136
+ };
3137
+
3138
+ const disconnectedCallback = elm => {
3139
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3140
+ disconnectRootElement(elm);
3141
+ }
3142
+ };
3143
+
3144
+ const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
3201
3145
  vnode.elm = elm;
3202
3146
  vnode.vm = vm;
3203
3147
  linkNodeToShadow(elm, owner, renderer);
@@ -3205,8 +3149,6 @@
3205
3149
 
3206
3150
  if (vm) {
3207
3151
  allocateChildren(vnode, vm);
3208
- } else if (vnode.ctor !== UpgradableConstructor) {
3209
- throw new TypeError(`Incorrect Component Constructor`);
3210
3152
  }
3211
3153
 
3212
3154
  patchElementPropsAndAttrs$1(null, vnode, renderer);
@@ -5562,19 +5504,23 @@
5562
5504
  //
5563
5505
  // Consequently, hydration mismatches will occur if scoped CSS token classnames
5564
5506
  // are rendered during SSR. This needs to be accounted for when validating.
5565
- if (scopedToken) {
5507
+ if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
5566
5508
  if (!isUndefined$1(className)) {
5567
- className = isNull(stylesheetTokenHost)
5568
- ? `${scopedToken} ${className}`
5569
- : `${scopedToken} ${className} ${stylesheetTokenHost}`;
5509
+ // The order of the className should be scopedToken className stylesheetTokenHost
5510
+ const classTokens = [scopedToken, className, stylesheetTokenHost];
5511
+ const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
5512
+ className = ArrayJoin.call(classNames, ' ');
5570
5513
  }
5571
5514
  else if (!isUndefined$1(classMap)) {
5572
- classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {} : { [stylesheetTokenHost]: true }));
5515
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
5573
5516
  }
5574
5517
  else {
5575
- className = isNull(stylesheetTokenHost)
5576
- ? `${scopedToken}`
5577
- : `${scopedToken} ${stylesheetTokenHost}`;
5518
+ // The order of the className should be scopedToken stylesheetTokenHost
5519
+ const classTokens = [scopedToken, stylesheetTokenHost];
5520
+ const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
5521
+ if (classNames.length) {
5522
+ className = ArrayJoin.call(classNames, ' ');
5523
+ }
5578
5524
  }
5579
5525
  }
5580
5526
  let nodesAreCompatible = true;
@@ -5703,7 +5649,7 @@
5703
5649
  }
5704
5650
  return ctor;
5705
5651
  }
5706
- /* version: 2.25.1 */
5652
+ /* version: 2.26.0 */
5707
5653
 
5708
5654
  /*
5709
5655
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5838,6 +5784,626 @@
5838
5784
  }
5839
5785
  }
5840
5786
 
5787
+ /*
5788
+ * Copyright (c) 2020, salesforce.com, inc.
5789
+ * All rights reserved.
5790
+ * SPDX-License-Identifier: MIT
5791
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5792
+ */
5793
+ function isCustomElementRegistryAvailable() {
5794
+ if (typeof customElements === 'undefined') {
5795
+ return false;
5796
+ }
5797
+ try {
5798
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
5799
+ // _wrapNativeSuper()
5800
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
5801
+ // get wrapped by babel.
5802
+ const HTMLElementAlias = HTMLElement;
5803
+ // In case we use compat mode with a modern browser, the compat mode transformation
5804
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
5805
+ // which are not equipped to be initialized that way.
5806
+ class clazz extends HTMLElementAlias {
5807
+ }
5808
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
5809
+ new clazz();
5810
+ return true;
5811
+ }
5812
+ catch (_a) {
5813
+ return false;
5814
+ }
5815
+ }
5816
+ const hasCustomElements = isCustomElementRegistryAvailable();
5817
+
5818
+ /*
5819
+ * Copyright (c) 2018, salesforce.com, inc.
5820
+ * All rights reserved.
5821
+ * SPDX-License-Identifier: MIT
5822
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5823
+ */
5824
+ // Creates a custom element for compat (legacy) browser environments
5825
+ const createCustomElementCompat = (tagName, upgradeCallback) => {
5826
+ const elm = document.createElement(tagName);
5827
+ upgradeCallback(elm); // nothing to do with the result for now
5828
+ return elm;
5829
+ };
5830
+
5831
+ /*
5832
+ * Copyright (c) 2018, salesforce.com, inc.
5833
+ * All rights reserved.
5834
+ * SPDX-License-Identifier: MIT
5835
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5836
+ */
5837
+ const cachedConstructors = new Map();
5838
+ const elementsUpgradedOutsideLWC = new WeakSet();
5839
+ let elementBeingUpgradedByLWC = false;
5840
+ // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
5841
+ // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
5842
+ // Another benefit is that only LWC can create components that actually do anything – if you do
5843
+ // `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
5844
+ // This class should be created once per tag name.
5845
+ const createUpgradableConstructor = (connectedCallback, disconnectedCallback) => {
5846
+ // TODO [#2972]: this class should expose observedAttributes as necessary
5847
+ return class UpgradableConstructor extends HTMLElement {
5848
+ constructor(upgradeCallback) {
5849
+ super();
5850
+ // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
5851
+ // then elementBeingUpgraded will be false
5852
+ if (elementBeingUpgradedByLWC) {
5853
+ upgradeCallback(this);
5854
+ }
5855
+ else {
5856
+ // keep track of elements that were not created by lwc.createElement,
5857
+ // so we can ignore their lifecycle hooks
5858
+ elementsUpgradedOutsideLWC.add(this);
5859
+ // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
5860
+ // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
5861
+ }
5862
+ }
5863
+ connectedCallback() {
5864
+ if (!elementsUpgradedOutsideLWC.has(this)) {
5865
+ connectedCallback(this);
5866
+ }
5867
+ }
5868
+ disconnectedCallback() {
5869
+ if (!elementsUpgradedOutsideLWC.has(this)) {
5870
+ disconnectedCallback(this);
5871
+ }
5872
+ }
5873
+ };
5874
+ };
5875
+ const createCustomElementVanilla = (tagName, upgradeCallback, connectedCallback, disconnectedCallback) => {
5876
+ // use global custom elements registry
5877
+ let UpgradableConstructor = cachedConstructors.get(tagName);
5878
+ if (isUndefined$1(UpgradableConstructor)) {
5879
+ if (!isUndefined$1(customElements.get(tagName))) {
5880
+ throw new Error(`Unexpected tag name "${tagName}". This name is a registered custom element, preventing LWC to upgrade the element.`);
5881
+ }
5882
+ UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
5883
+ customElements.define(tagName, UpgradableConstructor);
5884
+ cachedConstructors.set(tagName, UpgradableConstructor);
5885
+ }
5886
+ elementBeingUpgradedByLWC = true;
5887
+ try {
5888
+ return new UpgradableConstructor(upgradeCallback);
5889
+ }
5890
+ finally {
5891
+ elementBeingUpgradedByLWC = false;
5892
+ }
5893
+ };
5894
+
5895
+ /*
5896
+ * Copyright (c) 2020, salesforce.com, inc.
5897
+ * All rights reserved.
5898
+ * SPDX-License-Identifier: MIT
5899
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5900
+ */
5901
+ /**
5902
+ * Create a scoped registry, i.e. a function that can create custom elements whose tag names
5903
+ * do not conflict with vanilla custom elements having the same tag name.
5904
+ */
5905
+ function createScopedRegistry() {
5906
+ if (!hasCustomElements) {
5907
+ // This code should never be reached, because we don't use the pivot registry if
5908
+ // custom elements are unavailable.
5909
+ throw new Error('Custom elements are not supported in this environment.');
5910
+ }
5911
+ const { HTMLElement: NativeHTMLElement } = window;
5912
+ const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
5913
+ const definitionForElement = new WeakMap();
5914
+ const pendingRegistryForElement = new WeakMap();
5915
+ const definitionForConstructor = new WeakMap();
5916
+ const registeredUserCtors = new WeakSet();
5917
+ const pivotCtorByTag = new Map();
5918
+ const globalDefinitionsByTag = new Map();
5919
+ const globalDefinitionsByClass = new Map();
5920
+ const awaitingUpgrade = new Map();
5921
+ const EMPTY_SET = new Set();
5922
+ function createDefinitionRecord(constructor) {
5923
+ var _a;
5924
+ const { connectedCallback, disconnectedCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
5925
+ const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
5926
+ return {
5927
+ UserCtor: constructor,
5928
+ PivotCtor: undefined,
5929
+ connectedCallback,
5930
+ disconnectedCallback,
5931
+ adoptedCallback,
5932
+ attributeChangedCallback,
5933
+ observedAttributes,
5934
+ };
5935
+ }
5936
+ // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
5937
+ // element. Note that the `registeredDefinition` represents the constructor that was used to register during
5938
+ // `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
5939
+ // constructor is invoked with another constructor.
5940
+ function createPivotingClass(tagName, registeredDefinition) {
5941
+ class PivotCtor extends NativeHTMLElement {
5942
+ constructor(UserCtor) {
5943
+ // This constructor can only be invoked by:
5944
+ // a) the browser instantiating an element from parsing or via document.createElement.
5945
+ // b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
5946
+ // b) new UserClass.
5947
+ // When LWC instantiates it, it will pass the upgrading definition as an argument
5948
+ // If the caller signals via UserCtor that this is in fact a controlled
5949
+ // definition, we use that one, otherwise fallback to the global
5950
+ // internal registry.
5951
+ super();
5952
+ const userCtorIsDefined = !isUndefined$1(UserCtor);
5953
+ if (userCtorIsDefined) {
5954
+ if (!isConstructor(UserCtor)) {
5955
+ throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
5956
+ }
5957
+ if (!registeredUserCtors.has(UserCtor)) {
5958
+ throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
5959
+ }
5960
+ }
5961
+ const definition = userCtorIsDefined
5962
+ ? getOrCreateDefinitionForConstructor(UserCtor)
5963
+ : globalDefinitionsByTag.get(tagName);
5964
+ if (!isUndefined$1(definition)) {
5965
+ internalUpgrade(this, registeredDefinition, definition);
5966
+ }
5967
+ else {
5968
+ // This is the case in which there is no global definition, and
5969
+ // it is not handled by LWC (otherwise it will have a valid UserCtor)
5970
+ // so we need to add it to the pending queue just in case it eventually
5971
+ // gets defined in the global registry.
5972
+ pendingRegistryForElement.set(this, registeredDefinition);
5973
+ }
5974
+ }
5975
+ connectedCallback() {
5976
+ var _a;
5977
+ const definition = definitionForElement.get(this);
5978
+ if (!isUndefined$1(definition)) {
5979
+ // Delegate out to user callback
5980
+ (_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
5981
+ }
5982
+ else {
5983
+ // Register for upgrade when defined (only when connected, so we don't leak)
5984
+ let awaiting = awaitingUpgrade.get(tagName);
5985
+ if (isUndefined$1(awaiting)) {
5986
+ awaitingUpgrade.set(tagName, (awaiting = new Set()));
5987
+ }
5988
+ awaiting.add(this);
5989
+ }
5990
+ }
5991
+ disconnectedCallback() {
5992
+ var _a;
5993
+ const definition = definitionForElement.get(this);
5994
+ if (!isUndefined$1(definition)) {
5995
+ // Delegate out to user callback
5996
+ (_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
5997
+ }
5998
+ else {
5999
+ // Un-register for upgrade when defined (so we don't leak)
6000
+ const awaiting = awaitingUpgrade.get(tagName);
6001
+ // At this point, awaiting should never be undefined, because connectedCallback
6002
+ // must have been called before disconnectedCallback. But just to be safe, we check
6003
+ if (!isUndefined$1(awaiting)) {
6004
+ awaiting.delete(this);
6005
+ }
6006
+ }
6007
+ }
6008
+ adoptedCallback() {
6009
+ var _a;
6010
+ const definition = definitionForElement.get(this);
6011
+ (_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6012
+ }
6013
+ attributeChangedCallback(name, oldValue, newValue) {
6014
+ var _a;
6015
+ const definition = definitionForElement.get(this);
6016
+ // if both definitions are the same, then the observedAttributes is the same,
6017
+ // but if they are different, only if the runtime definition has the attribute
6018
+ // marked as observed, then it should invoke attributeChangedCallback.
6019
+ if (registeredDefinition === definition ||
6020
+ (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
6021
+ (_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
6022
+ }
6023
+ }
6024
+ }
6025
+ PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
6026
+ return PivotCtor;
6027
+ }
6028
+ function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
6029
+ const { observedAttributes, attributeChangedCallback } = pivotDefinition;
6030
+ if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
6031
+ // This instance does not need to observe any attributes, no need to patch
6032
+ return EMPTY_SET;
6033
+ }
6034
+ // Natively, the attributes observed by the registered definition are going to be taken
6035
+ // care of by the browser, only the difference between the two sets has to be taken
6036
+ // care by the patched version.
6037
+ return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
6038
+ }
6039
+ function throwAsyncError(error) {
6040
+ // Per native custom element behavior, errors thrown in attributeChangedCallback
6041
+ // become unhandled async errors. We use setTimeout() instead of Promise.resolve()
6042
+ // to make it an unhandled error rather than an unhandled rejection.
6043
+ setTimeout(() => {
6044
+ throw error;
6045
+ });
6046
+ }
6047
+ // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
6048
+ // Why is this necessary? Well basically, you can't change the `observedAttributes` after
6049
+ // a custom element is defined. So with pivots, if two classes share the same tag name,
6050
+ // and the second class observes attributes that aren't observed by the first one,
6051
+ // then those attributes can never be observed by the native `observedAttributes` system.
6052
+ // So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
6053
+ // we only do this when absolutely necessary, though; i.e. because we've determined
6054
+ // that we aren't observing the attributes we need to.
6055
+ function patchAttributes(instance, registeredDefinition, pivotDefinition) {
6056
+ const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
6057
+ if (newObservedAttributes.size === 0) {
6058
+ return;
6059
+ }
6060
+ const { attributeChangedCallback } = pivotDefinition;
6061
+ // Patch the instance.
6062
+ // Note we use the native `getAttribute` rather than the super's `getAttribute` because
6063
+ // we don't actually want it to be observable that we're calling `getAttribute` from
6064
+ // `setAttribute` and `removeAttribute`.
6065
+ // TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
6066
+ defineProperties(instance, {
6067
+ setAttribute: {
6068
+ value: function setAttribute(name, value) {
6069
+ if (newObservedAttributes.has(name)) {
6070
+ const old = nativeGetAttribute.call(this, name);
6071
+ nativeSetAttribute.call(this, name, value);
6072
+ try {
6073
+ attributeChangedCallback.call(this, name, old, value + '');
6074
+ }
6075
+ catch (error) {
6076
+ throwAsyncError(error);
6077
+ }
6078
+ }
6079
+ else {
6080
+ nativeSetAttribute.call(this, name, value);
6081
+ }
6082
+ },
6083
+ writable: true,
6084
+ enumerable: true,
6085
+ configurable: true,
6086
+ },
6087
+ removeAttribute: {
6088
+ value: function removeAttribute(name) {
6089
+ if (newObservedAttributes.has(name)) {
6090
+ const old = nativeGetAttribute.call(this, name);
6091
+ nativeRemoveAttribute.call(this, name);
6092
+ try {
6093
+ attributeChangedCallback.call(this, name, old, null);
6094
+ }
6095
+ catch (error) {
6096
+ throwAsyncError(error);
6097
+ }
6098
+ }
6099
+ else {
6100
+ nativeRemoveAttribute.call(this, name);
6101
+ }
6102
+ },
6103
+ writable: true,
6104
+ enumerable: true,
6105
+ configurable: true,
6106
+ },
6107
+ });
6108
+ }
6109
+ function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
6110
+ // The below case patches observed attributes for the case where the HTML element is upgraded
6111
+ // from a pre-existing one in the DOM.
6112
+ const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
6113
+ if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
6114
+ return;
6115
+ }
6116
+ const { attributeChangedCallback } = pivotDefinition;
6117
+ // Approximate observedAttributes from the user class, but only for the new observed attributes
6118
+ newObservedAttributes.forEach((name) => {
6119
+ if (nativeHasAttribute.call(instance, name)) {
6120
+ const newValue = nativeGetAttribute.call(instance, name);
6121
+ attributeChangedCallback.call(instance, name, null, newValue);
6122
+ }
6123
+ });
6124
+ }
6125
+ // User extends this HTMLElement, which returns the CE being upgraded
6126
+ let upgradingInstance;
6127
+ // Helper to upgrade an instance with a CE definition using "constructor call trick"
6128
+ function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
6129
+ setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
6130
+ definitionForElement.set(instance, pivotDefinition);
6131
+ // attributes patches when needed
6132
+ if (pivotDefinition !== registeredDefinition) {
6133
+ patchAttributes(instance, registeredDefinition, pivotDefinition);
6134
+ }
6135
+ // Tricking the construction path to believe that a new instance is being created,
6136
+ // that way it will execute the super initialization mechanism but the HTMLElement
6137
+ // constructor will reuse the instance by returning the upgradingInstance.
6138
+ // This is by far the most important piece of the puzzle
6139
+ upgradingInstance = instance;
6140
+ // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
6141
+ // The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
6142
+ // Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
6143
+ new pivotDefinition.UserCtor();
6144
+ patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
6145
+ }
6146
+ function isConstructor(constructor) {
6147
+ return isFunction$1(constructor) && isObject(constructor.prototype);
6148
+ }
6149
+ function getOrCreateDefinitionForConstructor(constructor) {
6150
+ if (!isConstructor(constructor)) {
6151
+ throw new TypeError('The referenced constructor is not a constructor.');
6152
+ }
6153
+ const definition = definitionForConstructor.get(constructor);
6154
+ if (!isUndefined$1(definition)) {
6155
+ return definition;
6156
+ }
6157
+ return createDefinitionRecord(constructor);
6158
+ }
6159
+ const { customElements: nativeRegistry } = window;
6160
+ const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
6161
+ // patch for the global registry define mechanism
6162
+ CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
6163
+ if (options && options.extends) {
6164
+ // TODO [#2983]: should we support `extends`?
6165
+ throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
6166
+ }
6167
+ if (globalDefinitionsByTag.has(tagName)) {
6168
+ throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
6169
+ }
6170
+ if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
6171
+ throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
6172
+ }
6173
+ const definition = getOrCreateDefinitionForConstructor(constructor);
6174
+ registeredUserCtors.add(constructor);
6175
+ let PivotCtor = pivotCtorByTag.get(tagName);
6176
+ if (isUndefined$1(PivotCtor)) {
6177
+ PivotCtor = createPivotingClass(tagName, definition);
6178
+ // Register a pivoting class which will handle global registry initializations
6179
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
6180
+ }
6181
+ // Only cache after nativeDefine has been called, because if it throws an error
6182
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
6183
+ definitionForConstructor.set(constructor, definition);
6184
+ pivotCtorByTag.set(tagName, PivotCtor);
6185
+ globalDefinitionsByTag.set(tagName, definition);
6186
+ globalDefinitionsByClass.set(constructor, definition);
6187
+ // For globally defined custom elements, the definition associated
6188
+ // to the UserCtor has a back-pointer to PivotCtor in case the user
6189
+ // new the UserCtor, so we know how to create the underlying element.
6190
+ definition.PivotCtor = PivotCtor;
6191
+ // Upgrade any elements created in this scope before customElements.define
6192
+ // was called, which should be exhibited by the following steps:
6193
+ // 1) LWC registers a tagName for an LWC component.
6194
+ // 2) Element with same tagName is created with document.createElement()
6195
+ // and inserted into DOM.
6196
+ // 3) customElements.define() is called with tagName and non-LWC constructor.
6197
+ // This requires immediate upgrade when the new global tagName is defined.
6198
+ const awaiting = awaitingUpgrade.get(tagName);
6199
+ if (!isUndefined$1(awaiting)) {
6200
+ awaitingUpgrade.delete(tagName);
6201
+ for (const element of awaiting) {
6202
+ const registeredDefinition = pendingRegistryForElement.get(element);
6203
+ // At this point, registeredDefinition should never be undefined because awaitingUpgrade
6204
+ // is only populated when we haven't run internalUpgrade yet, and we only populate
6205
+ // pendingRegistryForElement when internalUpgrade hasn't run yet.
6206
+ // But just to be safe, we check.
6207
+ if (!isUndefined$1(registeredDefinition)) {
6208
+ pendingRegistryForElement.delete(element);
6209
+ internalUpgrade(element, registeredDefinition, definition);
6210
+ }
6211
+ }
6212
+ }
6213
+ };
6214
+ CustomElementRegistry.prototype.get = function get(tagName) {
6215
+ const NativeCtor = nativeGet.call(nativeRegistry, tagName);
6216
+ if (!isUndefined$1(NativeCtor)) {
6217
+ const definition = globalDefinitionsByTag.get(tagName);
6218
+ if (!isUndefined$1(definition)) {
6219
+ return definition.UserCtor; // defined by the patched custom elements registry
6220
+ }
6221
+ // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
6222
+ return NativeCtor; // return the pivot constructor or constructor that existed before patching
6223
+ }
6224
+ };
6225
+ CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
6226
+ return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
6227
+ const definition = globalDefinitionsByTag.get(tagName);
6228
+ if (!isUndefined$1(definition)) {
6229
+ return definition.UserCtor;
6230
+ }
6231
+ // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
6232
+ // In this case, the custom element must have been defined before the registry patches
6233
+ // were applied. So return the non-pivot constructor
6234
+ if (isUndefined$1(NativeCtor)) {
6235
+ // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
6236
+ // We can patch the correct behavior using customElements.get()
6237
+ return nativeGet.call(nativeRegistry, tagName);
6238
+ }
6239
+ return NativeCtor;
6240
+ });
6241
+ };
6242
+ // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
6243
+ // @ts-ignore
6244
+ window.HTMLElement = function HTMLElement() {
6245
+ // Upgrading case: the pivoting class constructor was run by the browser's
6246
+ // native custom elements and we're in the process of running the
6247
+ // "constructor-call trick" on the natively constructed instance, so just
6248
+ // return that here.
6249
+ // This code path is also called when LWC `new`s a PivotCtor.
6250
+ const instance = upgradingInstance;
6251
+ if (!isUndefined$1(instance)) {
6252
+ upgradingInstance = undefined;
6253
+ return instance;
6254
+ }
6255
+ // Construction case: we need to construct the pivoting instance and return it.
6256
+ // This is possible when the user register it via global registry and instantiate
6257
+ // it via `new Ctor()`.
6258
+ const { constructor } = this;
6259
+ const definition = globalDefinitionsByClass.get(constructor);
6260
+ if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
6261
+ // This code path is hit if someone `new`s a class that extends `HTMLElement` without
6262
+ // doing `customElements.define()` first. This matches native browser behavior:
6263
+ // https://stackoverflow.com/a/61883392
6264
+ throw new TypeError('Illegal constructor');
6265
+ }
6266
+ // This constructor is ONLY invoked when it is the user instantiating
6267
+ // an element via new Ctor while Ctor is a registered global constructor.
6268
+ const { PivotCtor, UserCtor } = definition;
6269
+ return new PivotCtor(UserCtor);
6270
+ };
6271
+ HTMLElement.prototype = NativeHTMLElement.prototype;
6272
+ /**
6273
+ * Create a new PivotConstructor for the given tagName, which is capable of being constructed
6274
+ * with a UserConstructor defining the behavior. Passing in the UserConstructor here
6275
+ * is a hint that can be used when registering a custom element with the global custom elements
6276
+ * registry for the first time, which provides certain optimizations. It also marks the UserConstructor
6277
+ * as "safe" to be used when passed in to a PivotConstructor.
6278
+ *
6279
+ * @param tagName - element tag name
6280
+ * @param UserCtor - userland custom element constructor
6281
+ * @returns a new custom element constructor
6282
+ */
6283
+ return function createPivotConstructor(tagName, UserCtor) {
6284
+ tagName = StringToLowerCase.call(tagName);
6285
+ let PivotCtor = pivotCtorByTag.get(tagName);
6286
+ if (isUndefined$1(PivotCtor)) {
6287
+ const definition = getOrCreateDefinitionForConstructor(UserCtor);
6288
+ PivotCtor = createPivotingClass(tagName, definition);
6289
+ // Register a pivoting class as a global custom element
6290
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
6291
+ definition.PivotCtor = PivotCtor;
6292
+ // Only cache after nativeDefine has been called, because if it throws an error
6293
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
6294
+ definitionForConstructor.set(UserCtor, definition);
6295
+ pivotCtorByTag.set(tagName, PivotCtor);
6296
+ }
6297
+ // Register a UserConstructor as "safe" to be used within a PivotConstructor
6298
+ registeredUserCtors.add(UserCtor);
6299
+ return PivotCtor;
6300
+ };
6301
+ }
6302
+
6303
+ /*
6304
+ * Copyright (c) 2018, salesforce.com, inc.
6305
+ * All rights reserved.
6306
+ * SPDX-License-Identifier: MIT
6307
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6308
+ */
6309
+ let createScopedConstructor;
6310
+ let CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
6311
+ // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
6312
+ // or we're in a legacy browser.
6313
+
6314
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
6315
+ if (hasCustomElements) {
6316
+ // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
6317
+ // It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
6318
+ //
6319
+ // Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
6320
+ //
6321
+ // 1. LWC loads
6322
+ // 2. `const Ctor = class extends HTMLElement {}`
6323
+ // 3. `lwc.createElement(...)` // here we lazily patch
6324
+ // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
6325
+ //
6326
+ // To reduce the risk of this, it's safer to patch the registry eagerly.
6327
+ createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
6328
+ // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
6329
+ // because the HTMLElement prototypes are mixed up.
6330
+ //
6331
+ // The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
6332
+ // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
6333
+ // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
6334
+ // Caching avoids this problem.
6335
+
6336
+ CachedHTMLElement = window.HTMLElement;
6337
+ }
6338
+ } // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
6339
+ // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
6340
+ // multiple times per tag name.
6341
+
6342
+
6343
+ const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
6344
+ // TODO [#2972]: this class should expose observedAttributes as necessary
6345
+ return class UserConstructor extends HTMLElementToExtend {
6346
+ constructor() {
6347
+ super();
6348
+ upgradeCallback(this);
6349
+ }
6350
+
6351
+ connectedCallback() {
6352
+ connectedCallback(this);
6353
+ }
6354
+
6355
+ disconnectedCallback() {
6356
+ disconnectedCallback(this);
6357
+ }
6358
+
6359
+ };
6360
+ };
6361
+
6362
+ function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
6363
+ if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
6364
+ // This error should be impossible to hit
6365
+ throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
6366
+ }
6367
+
6368
+ const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
6369
+ const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
6370
+ return new ScopedConstructor(UserConstructor);
6371
+ }
6372
+
6373
+ /*
6374
+ * Copyright (c) 2018, salesforce.com, inc.
6375
+ * All rights reserved.
6376
+ * SPDX-License-Identifier: MIT
6377
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6378
+ */
6379
+ /**
6380
+ * We have three modes for creating custom elements:
6381
+ *
6382
+ * 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
6383
+ * 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
6384
+ * same tag name, via a simple trick: every custom element constructor we define in the registry is basically
6385
+ * the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
6386
+ * constructor, which allows us to have completely customized functionality for different components.
6387
+ * 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
6388
+ * elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
6389
+ * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
6390
+ * because it must patch the global `customElements` and `HTMLElement` objects.
6391
+ */
6392
+
6393
+ let createCustomElement;
6394
+
6395
+ if (hasCustomElements) {
6396
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
6397
+ createCustomElement = createCustomElementScoped;
6398
+ } else {
6399
+ // use global custom elements registry (vanilla)
6400
+ createCustomElement = createCustomElementVanilla;
6401
+ }
6402
+ } else {
6403
+ // no registry available here
6404
+ createCustomElement = createCustomElementCompat;
6405
+ }
6406
+
5841
6407
  /*
5842
6408
  * Copyright (c) 2018, salesforce.com, inc.
5843
6409
  * All rights reserved.
@@ -5898,7 +6464,7 @@
5898
6464
  function isNull(obj) {
5899
6465
  return obj === null;
5900
6466
  }
5901
- /** version: 2.25.1 */
6467
+ /** version: 2.26.0 */
5902
6468
 
5903
6469
  /*
5904
6470
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5906,65 +6472,6 @@
5906
6472
  * SPDX-License-Identifier: MIT
5907
6473
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5908
6474
  */
5909
- exports.getCustomElement = void 0;
5910
- exports.defineCustomElement = void 0;
5911
- let HTMLElementConstructor;
5912
- function isCustomElementRegistryAvailable() {
5913
- if (typeof customElements === 'undefined') {
5914
- return false;
5915
- }
5916
- try {
5917
- // dereference HTMLElement global because babel wraps globals in compat mode with a
5918
- // _wrapNativeSuper()
5919
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
5920
- // get wrapped by babel.
5921
- const HTMLElementAlias = HTMLElement;
5922
- // In case we use compat mode with a modern browser, the compat mode transformation
5923
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
5924
- // which are not equipped to be initialized that way.
5925
- class clazz extends HTMLElementAlias {
5926
- }
5927
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
5928
- new clazz();
5929
- return true;
5930
- }
5931
- catch (_a) {
5932
- return false;
5933
- }
5934
- }
5935
- if (isCustomElementRegistryAvailable()) {
5936
- exports.getCustomElement = customElements.get.bind(customElements);
5937
- exports.defineCustomElement = customElements.define.bind(customElements);
5938
- HTMLElementConstructor = HTMLElement;
5939
- }
5940
- else {
5941
- const registry = Object.create(null);
5942
- const reverseRegistry = new WeakMap();
5943
- exports.defineCustomElement = function define(name, ctor) {
5944
- if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
5945
- throw new TypeError(`Invalid Registration`);
5946
- }
5947
- registry[name] = ctor;
5948
- reverseRegistry.set(ctor, name);
5949
- };
5950
- exports.getCustomElement = function get(name) {
5951
- return registry[name];
5952
- };
5953
- HTMLElementConstructor = function HTMLElement() {
5954
- if (!(this instanceof HTMLElement)) {
5955
- throw new TypeError(`Invalid Invocation`);
5956
- }
5957
- const { constructor } = this;
5958
- const name = reverseRegistry.get(constructor);
5959
- if (!name) {
5960
- throw new TypeError(`Invalid Construction`);
5961
- }
5962
- const elm = document.createElement(name);
5963
- Object.setPrototypeOf(elm, constructor.prototype);
5964
- return elm;
5965
- };
5966
- HTMLElementConstructor.prototype = HTMLElement.prototype;
5967
- }
5968
6475
  function cloneNode(node, deep) {
5969
6476
  return node.cloneNode(deep);
5970
6477
  }
@@ -6138,9 +6645,7 @@
6138
6645
  function assertInstanceOfHTMLElement(elm, msg) {
6139
6646
  assert.invariant(elm instanceof HTMLElement, msg);
6140
6647
  }
6141
- const HTMLElementExported = HTMLElementConstructor;
6142
6648
 
6143
- exports.HTMLElementExported = HTMLElementExported;
6144
6649
  exports.addEventListener = addEventListener;
6145
6650
  exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
6146
6651
  exports.attachShadow = attachShadow;
@@ -6200,6 +6705,8 @@
6200
6705
  {
6201
6706
  // insertStyleSheet implementation shares a global cache of stylesheet data
6202
6707
  insertStylesheet,
6708
+ // relies on a shared global cache
6709
+ createCustomElement,
6203
6710
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
6204
6711
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
6205
6712
  });
@@ -6295,36 +6802,44 @@
6295
6802
  // This WeakSet usage is valid because this functionality is not meant to run in IE11.
6296
6803
  const hydratedCustomElements = new WeakSet();
6297
6804
  function buildCustomElementConstructor(Ctor) {
6805
+ var _a;
6298
6806
  const HtmlPrototype = getComponentHtmlPrototype(Ctor);
6299
- return class extends HtmlPrototype {
6300
- constructor() {
6301
- super();
6302
- if (this.isConnected) {
6303
- // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6304
- hydrateComponent(this, Ctor, {});
6305
- hydratedCustomElements.add(this);
6807
+ const { observedAttributes } = HtmlPrototype;
6808
+ const { attributeChangedCallback } = HtmlPrototype.prototype;
6809
+ return _a = class extends HTMLElement {
6810
+ constructor() {
6811
+ super();
6812
+ if (this.isConnected) {
6813
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6814
+ hydrateComponent(this, Ctor, {});
6815
+ hydratedCustomElements.add(this);
6816
+ }
6817
+ else {
6818
+ createVM(this, Ctor, renderer, {
6819
+ mode: 'open',
6820
+ owner: null,
6821
+ tagName: this.tagName,
6822
+ });
6823
+ }
6306
6824
  }
6307
- else {
6308
- createVM(this, Ctor, renderer, {
6309
- mode: 'open',
6310
- owner: null,
6311
- tagName: this.tagName,
6312
- });
6825
+ connectedCallback() {
6826
+ if (hydratedCustomElements.has(this)) {
6827
+ // This is an un-upgraded element that was hydrated in the constructor.
6828
+ hydratedCustomElements.delete(this);
6829
+ }
6830
+ else {
6831
+ connectRootElement(this);
6832
+ }
6313
6833
  }
6314
- }
6315
- connectedCallback() {
6316
- if (hydratedCustomElements.has(this)) {
6317
- // This is an un-upgraded element that was hydrated in the constructor.
6318
- hydratedCustomElements.delete(this);
6834
+ disconnectedCallback() {
6835
+ disconnectRootElement(this);
6319
6836
  }
6320
- else {
6321
- connectRootElement(this);
6837
+ attributeChangedCallback(name, oldValue, newValue) {
6838
+ attributeChangedCallback.call(this, name, oldValue, newValue);
6322
6839
  }
6323
- }
6324
- disconnectedCallback() {
6325
- disconnectRootElement(this);
6326
- }
6327
- };
6840
+ },
6841
+ _a.observedAttributes = observedAttributes,
6842
+ _a;
6328
6843
  }
6329
6844
 
6330
6845
  /*
@@ -6408,8 +6923,13 @@
6408
6923
  throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
6409
6924
  }
6410
6925
 
6411
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
6412
- let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
6926
+ const {
6927
+ createCustomElement
6928
+ } = renderer; // tagName must be all lowercase, unfortunately, we have legacy code that is
6929
+ // passing `sel` as a camel-case, which makes them invalid custom elements name
6930
+ // the following line guarantees that this does not leaks beyond this point.
6931
+
6932
+ const tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
6413
6933
 
6414
6934
  /**
6415
6935
  * Note: if the upgradable constructor does not expect, or throw when we new it
@@ -6418,9 +6938,9 @@
6418
6938
  * an upgradable custom element.
6419
6939
  */
6420
6940
 
6421
- const element = new UpgradableConstructor(elm => {
6941
+ const upgradeCallback = elm => {
6422
6942
  createVM(elm, Ctor, renderer, {
6423
- tagName: sel,
6943
+ tagName,
6424
6944
  mode: options.mode !== 'closed' ? 'open' : 'closed',
6425
6945
  owner: null
6426
6946
  });
@@ -6429,15 +6949,21 @@
6429
6949
  ConnectingSlot.set(elm, connectRootElement);
6430
6950
  DisconnectingSlot.set(elm, disconnectRootElement);
6431
6951
  }
6952
+ };
6432
6953
 
6433
- wasComponentUpgraded = true;
6434
- });
6954
+ const connectedCallback = elm => {
6955
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6956
+ connectRootElement(elm);
6957
+ }
6958
+ };
6435
6959
 
6436
- if (!wasComponentUpgraded) {
6437
- /* eslint-disable-next-line no-console */
6438
- console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
6439
- }
6960
+ const disconnectedCallback = elm => {
6961
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6962
+ disconnectRootElement(elm);
6963
+ }
6964
+ };
6440
6965
 
6966
+ const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
6441
6967
  return element;
6442
6968
  }
6443
6969
 
@@ -6509,7 +7035,7 @@
6509
7035
  });
6510
7036
  freeze(LightningElement);
6511
7037
  seal(LightningElement.prototype);
6512
- /* version: 2.25.1 */
7038
+ /* version: 2.26.0 */
6513
7039
 
6514
7040
  exports.LightningElement = LightningElement;
6515
7041
  exports.__unstable__ProfilerControl = profilerControl;