lwc 2.25.1 → 2.26.1

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