lwc 2.25.0 → 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 +1103 -533
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1103 -533
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +942 -320
  5. package/dist/engine-dom/iife/es5/engine-dom.js +966 -312
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +895 -225
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1103 -533
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +942 -320
  11. package/dist/engine-dom/umd/es5/engine-dom.js +966 -312
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +895 -225
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +331 -339
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +331 -339
  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
@@ -120,6 +120,7 @@ var LWC = (function (exports) {
120
120
  setPrototypeOf = Object.setPrototypeOf;
121
121
  var isArray$1 = Array.isArray;
122
122
  var _Array$prototype = Array.prototype,
123
+ ArrayFilter = _Array$prototype.filter,
123
124
  ArrayIndexOf = _Array$prototype.indexOf,
124
125
  ArrayJoin = _Array$prototype.join,
125
126
  ArrayMap = _Array$prototype.map,
@@ -346,7 +347,7 @@ var LWC = (function (exports) {
346
347
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
347
348
  return attributeName;
348
349
  }
349
- /** version: 2.25.0 */
350
+ /** version: 2.26.0 */
350
351
 
351
352
  /**
352
353
  * Copyright (C) 2018 salesforce.com, inc.
@@ -440,7 +441,7 @@ var LWC = (function (exports) {
440
441
  patch$1(propName);
441
442
  }
442
443
  }
443
- /** version: 2.25.0 */
444
+ /** version: 2.26.0 */
444
445
 
445
446
  /**
446
447
  * Copyright (C) 2018 salesforce.com, inc.
@@ -458,7 +459,6 @@ var LWC = (function (exports) {
458
459
  DUMMY_TEST_FLAG: null,
459
460
  ENABLE_ELEMENT_PATCH: null,
460
461
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
461
- ENABLE_HMR: null,
462
462
  ENABLE_HTML_COLLECTIONS_PATCH: null,
463
463
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
464
464
  ENABLE_MIXED_SHADOW_MODE: null,
@@ -467,7 +467,9 @@ var LWC = (function (exports) {
467
467
  ENABLE_NODE_PATCH: null,
468
468
  ENABLE_REACTIVE_SETTER: null,
469
469
  ENABLE_WIRE_SYNC_EMIT: null,
470
- ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null
470
+ ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
471
+ DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
472
+ ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
471
473
  };
472
474
 
473
475
  if (!_globalThis.lwcRuntimeFlags) {
@@ -1793,7 +1795,9 @@ var LWC = (function (exports) {
1793
1795
  var LightningElement = function LightningElement() {
1794
1796
  // This should be as performant as possible, while any initialization should be done lazily
1795
1797
  if (isNull(vmBeingConstructed)) {
1796
- throw new ReferenceError('Illegal constructor');
1798
+ // Thrown when doing something like `new LightningElement()` or
1799
+ // `class Foo extends LightningElement {}; new Foo()`
1800
+ throw new TypeError('Illegal constructor');
1797
1801
  }
1798
1802
 
1799
1803
  var vm = vmBeingConstructed;
@@ -2765,33 +2769,21 @@ var LWC = (function (exports) {
2765
2769
  {
2766
2770
  // this method should never leak to prod
2767
2771
  throw new ReferenceError();
2768
- }
2772
+ } // tracking active component
2769
2773
  }
2770
2774
 
2771
2775
  function swapTemplate(oldTpl, newTpl) {
2772
2776
 
2773
- if (!lwcRuntimeFlags.ENABLE_HMR) {
2774
- throw new Error('HMR is not enabled');
2775
- }
2776
-
2777
2777
  return false;
2778
2778
  }
2779
2779
 
2780
2780
  function swapComponent(oldComponent, newComponent) {
2781
2781
 
2782
- if (!lwcRuntimeFlags.ENABLE_HMR) {
2783
- throw new Error('HMR is not enabled');
2784
- }
2785
-
2786
2782
  return false;
2787
2783
  }
2788
2784
 
2789
2785
  function swapStyle(oldStyle, newStyle) {
2790
2786
 
2791
- if (!lwcRuntimeFlags.ENABLE_HMR) {
2792
- throw new Error('HMR is not enabled');
2793
- }
2794
-
2795
2787
  return false;
2796
2788
  }
2797
2789
  /*
@@ -3118,7 +3110,17 @@ var LWC = (function (exports) {
3118
3110
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
3119
3111
  } else {
3120
3112
 
3121
- var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
3113
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS];
3114
+
3115
+ if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
3116
+ if (!isScopedCss && vm.renderMode === 0
3117
+ /* RenderMode.Light */
3118
+ ) {
3119
+ logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
3120
+ continue;
3121
+ }
3122
+ } // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
3123
+
3122
3124
 
3123
3125
  var scopeToken = isScopedCss || vm.shadowMode === 1
3124
3126
  /* ShadowMode.Synthetic */
@@ -3207,14 +3209,17 @@ var LWC = (function (exports) {
3207
3209
  /**
3208
3210
  * This function returns the host style token for a custom element if it
3209
3211
  * exists. Otherwise it returns null.
3212
+ *
3213
+ * A host style token is applied to the component if scoped styles are used.
3210
3214
  */
3211
3215
 
3212
3216
 
3213
3217
  function getStylesheetTokenHost(vnode) {
3214
3218
  var _getComponentInternal = getComponentInternalDef(vnode.ctor),
3215
- stylesheetToken = _getComponentInternal.template.stylesheetToken;
3219
+ template = _getComponentInternal.template;
3216
3220
 
3217
- return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
3221
+ var stylesheetToken = template.stylesheetToken;
3222
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
3218
3223
  }
3219
3224
 
3220
3225
  function getNearestNativeShadowComponent(vm) {
@@ -3263,78 +3268,6 @@ var LWC = (function (exports) {
3263
3268
 
3264
3269
  return null;
3265
3270
  }
3266
- /*
3267
- * Copyright (c) 2020, salesforce.com, inc.
3268
- * All rights reserved.
3269
- * SPDX-License-Identifier: MIT
3270
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3271
- */
3272
-
3273
-
3274
- function checkHasVM(elm) {
3275
- var hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
3276
-
3277
- return hasVM;
3278
- }
3279
-
3280
- function getUpgradableConstructor(tagName, renderer) {
3281
- var getCustomElement = renderer.getCustomElement,
3282
- RendererHTMLElement = renderer.HTMLElementExported,
3283
- defineCustomElement = renderer.defineCustomElement; // Should never get a tag with upper case letter at this point, the compiler should
3284
- // produce only tags with lowercase letters
3285
- // But, for backwards compatibility, we will lower case the tagName
3286
-
3287
- tagName = tagName.toLowerCase();
3288
- var CE = getCustomElement(tagName);
3289
-
3290
- if (!isUndefined$1(CE)) {
3291
- return CE;
3292
- }
3293
- /**
3294
- * LWC Upgradable Element reference to an element that was created
3295
- * via the scoped registry mechanism, and that is ready to be upgraded.
3296
- */
3297
-
3298
-
3299
- CE = /*#__PURE__*/function (_RendererHTMLElement) {
3300
- _inherits(LWCUpgradableElement, _RendererHTMLElement);
3301
-
3302
- var _super5 = _createSuper(LWCUpgradableElement);
3303
-
3304
- function LWCUpgradableElement(upgradeCallback) {
3305
- var _this4;
3306
-
3307
- _classCallCheck(this, LWCUpgradableElement);
3308
-
3309
- _this4 = _super5.call(this);
3310
-
3311
- if (isFunction$1(upgradeCallback)) {
3312
- upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
3313
- }
3314
-
3315
- return _this4;
3316
- }
3317
-
3318
- return _createClass(LWCUpgradableElement);
3319
- }(RendererHTMLElement);
3320
-
3321
- if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3322
- CE.prototype.connectedCallback = function () {
3323
- if (checkHasVM(this)) {
3324
- connectRootElement(this);
3325
- }
3326
- };
3327
-
3328
- CE.prototype.disconnectedCallback = function () {
3329
- if (checkHasVM(this)) {
3330
- disconnectRootElement(this);
3331
- }
3332
- };
3333
- }
3334
-
3335
- defineCustomElement(tagName, CE);
3336
- return CE;
3337
- }
3338
3271
  /*
3339
3272
  * Copyright (c) 2018, salesforce.com, inc.
3340
3273
  * All rights reserved.
@@ -3867,7 +3800,7 @@ var LWC = (function (exports) {
3867
3800
  function mountCustomElement(vnode, parent, anchor, renderer) {
3868
3801
  var sel = vnode.sel,
3869
3802
  owner = vnode.owner;
3870
- var UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3803
+ var createCustomElement = renderer.createCustomElement;
3871
3804
  /**
3872
3805
  * Note: if the upgradable constructor does not expect, or throw when we new it
3873
3806
  * with a callback as the first argument, we could implement a more advanced
@@ -3876,10 +3809,25 @@ var LWC = (function (exports) {
3876
3809
  */
3877
3810
 
3878
3811
  var vm;
3879
- var elm = new UpgradableConstructor(function (elm) {
3812
+
3813
+ var upgradeCallback = function upgradeCallback(elm) {
3880
3814
  // the custom element from the registry is expecting an upgrade callback
3881
3815
  vm = createViewModelHook(elm, vnode, renderer);
3882
- });
3816
+ };
3817
+
3818
+ var connectedCallback = function connectedCallback(elm) {
3819
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3820
+ connectRootElement(elm);
3821
+ }
3822
+ };
3823
+
3824
+ var disconnectedCallback = function disconnectedCallback(elm) {
3825
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3826
+ disconnectRootElement(elm);
3827
+ }
3828
+ };
3829
+
3830
+ var elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
3883
3831
  vnode.elm = elm;
3884
3832
  vnode.vm = vm;
3885
3833
  linkNodeToShadow(elm, owner, renderer);
@@ -3887,8 +3835,6 @@ var LWC = (function (exports) {
3887
3835
 
3888
3836
  if (vm) {
3889
3837
  allocateChildren(vnode, vm);
3890
- } else if (vnode.ctor !== UpgradableConstructor) {
3891
- throw new TypeError("Incorrect Component Constructor");
3892
3838
  }
3893
3839
 
3894
3840
  patchElementPropsAndAttrs$1(null, vnode, renderer);
@@ -5863,21 +5809,21 @@ var LWC = (function (exports) {
5863
5809
  var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
5864
5810
  _inherits(WireContextRegistrationEvent, _CustomEvent);
5865
5811
 
5866
- var _super6 = _createSuper(WireContextRegistrationEvent);
5812
+ var _super5 = _createSuper(WireContextRegistrationEvent);
5867
5813
 
5868
5814
  function WireContextRegistrationEvent(adapterToken, _ref3) {
5869
- var _this5;
5815
+ var _this4;
5870
5816
 
5871
5817
  var setNewContext = _ref3.setNewContext,
5872
5818
  setDisconnectedCallback = _ref3.setDisconnectedCallback;
5873
5819
 
5874
5820
  _classCallCheck(this, WireContextRegistrationEvent);
5875
5821
 
5876
- _this5 = _super6.call(this, adapterToken, {
5822
+ _this4 = _super5.call(this, adapterToken, {
5877
5823
  bubbles: true,
5878
5824
  composed: true
5879
5825
  });
5880
- defineProperties(_assertThisInitialized(_this5), {
5826
+ defineProperties(_assertThisInitialized(_this4), {
5881
5827
  setNewContext: {
5882
5828
  value: setNewContext
5883
5829
  },
@@ -5885,7 +5831,7 @@ var LWC = (function (exports) {
5885
5831
  value: setDisconnectedCallback
5886
5832
  }
5887
5833
  });
5888
- return _this5;
5834
+ return _this4;
5889
5835
  }
5890
5836
 
5891
5837
  return _createClass(WireContextRegistrationEvent);
@@ -6524,13 +6470,27 @@ var LWC = (function (exports) {
6524
6470
  // Consequently, hydration mismatches will occur if scoped CSS token classnames
6525
6471
  // are rendered during SSR. This needs to be accounted for when validating.
6526
6472
 
6527
- if (scopedToken) {
6473
+ if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
6528
6474
  if (!isUndefined$1(className)) {
6529
- className = isNull(stylesheetTokenHost) ? "".concat(scopedToken, " ").concat(className) : "".concat(scopedToken, " ").concat(className, " ").concat(stylesheetTokenHost);
6475
+ // The order of the className should be scopedToken className stylesheetTokenHost
6476
+ var classTokens = [scopedToken, className, stylesheetTokenHost];
6477
+ var classNames = ArrayFilter.call(classTokens, function (token) {
6478
+ return !isNull(token);
6479
+ });
6480
+ className = ArrayJoin.call(classNames, ' ');
6530
6481
  } else if (!isUndefined$1(classMap)) {
6531
- classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ? {} : _defineProperty({}, stylesheetTokenHost, true));
6482
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), !isNull(scopedToken) ? _defineProperty({}, scopedToken, true) : {}), !isNull(stylesheetTokenHost) ? _defineProperty({}, stylesheetTokenHost, true) : {});
6532
6483
  } else {
6533
- className = isNull(stylesheetTokenHost) ? "".concat(scopedToken) : "".concat(scopedToken, " ").concat(stylesheetTokenHost);
6484
+ // The order of the className should be scopedToken stylesheetTokenHost
6485
+ var _classTokens = [scopedToken, stylesheetTokenHost];
6486
+
6487
+ var _classNames = ArrayFilter.call(_classTokens, function (token) {
6488
+ return !isNull(token);
6489
+ });
6490
+
6491
+ if (_classNames.length) {
6492
+ className = ArrayJoin.call(_classNames, ' ');
6493
+ }
6534
6494
  }
6535
6495
  }
6536
6496
 
@@ -6701,7 +6661,7 @@ var LWC = (function (exports) {
6701
6661
 
6702
6662
  return ctor;
6703
6663
  }
6704
- /* version: 2.25.0 */
6664
+ /* version: 2.26.0 */
6705
6665
 
6706
6666
  /*
6707
6667
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6852,6 +6812,779 @@ var LWC = (function (exports) {
6852
6812
  insertLocalStylesheet(content, target);
6853
6813
  }
6854
6814
  }
6815
+ /*
6816
+ * Copyright (c) 2020, salesforce.com, inc.
6817
+ * All rights reserved.
6818
+ * SPDX-License-Identifier: MIT
6819
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6820
+ */
6821
+
6822
+
6823
+ function isCustomElementRegistryAvailable() {
6824
+ if (typeof customElements === 'undefined') {
6825
+ return false;
6826
+ }
6827
+
6828
+ try {
6829
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
6830
+ // _wrapNativeSuper()
6831
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
6832
+ // get wrapped by babel.
6833
+ var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
6834
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
6835
+ // which are not equipped to be initialized that way.
6836
+
6837
+ var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
6838
+ _inherits(clazz, _HTMLElementAlias);
6839
+
6840
+ var _super6 = _createSuper(clazz);
6841
+
6842
+ function clazz() {
6843
+ _classCallCheck(this, clazz);
6844
+
6845
+ return _super6.apply(this, arguments);
6846
+ }
6847
+
6848
+ return _createClass(clazz);
6849
+ }(HTMLElementAlias);
6850
+
6851
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
6852
+ new clazz();
6853
+ return true;
6854
+ } catch (_a) {
6855
+ return false;
6856
+ }
6857
+ }
6858
+
6859
+ var hasCustomElements = isCustomElementRegistryAvailable();
6860
+ /*
6861
+ * Copyright (c) 2018, salesforce.com, inc.
6862
+ * All rights reserved.
6863
+ * SPDX-License-Identifier: MIT
6864
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6865
+ */
6866
+ // Creates a custom element for compat (legacy) browser environments
6867
+
6868
+ var createCustomElementCompat = function createCustomElementCompat(tagName, upgradeCallback) {
6869
+ var elm = document.createElement(tagName);
6870
+ upgradeCallback(elm); // nothing to do with the result for now
6871
+
6872
+ return elm;
6873
+ };
6874
+ /*
6875
+ * Copyright (c) 2018, salesforce.com, inc.
6876
+ * All rights reserved.
6877
+ * SPDX-License-Identifier: MIT
6878
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6879
+ */
6880
+
6881
+
6882
+ var cachedConstructors = new Map();
6883
+ var elementsUpgradedOutsideLWC = new WeakSet();
6884
+ var elementBeingUpgradedByLWC = false; // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
6885
+ // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
6886
+ // Another benefit is that only LWC can create components that actually do anything – if you do
6887
+ // `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
6888
+ // This class should be created once per tag name.
6889
+
6890
+ var createUpgradableConstructor = function createUpgradableConstructor(_connectedCallback, _disconnectedCallback) {
6891
+ // TODO [#2972]: this class should expose observedAttributes as necessary
6892
+ return /*#__PURE__*/function (_HTMLElement) {
6893
+ _inherits(UpgradableConstructor, _HTMLElement);
6894
+
6895
+ var _super7 = _createSuper(UpgradableConstructor);
6896
+
6897
+ function UpgradableConstructor(upgradeCallback) {
6898
+ var _this5;
6899
+
6900
+ _classCallCheck(this, UpgradableConstructor);
6901
+
6902
+ _this5 = _super7.call(this); // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
6903
+ // then elementBeingUpgraded will be false
6904
+
6905
+ if (elementBeingUpgradedByLWC) {
6906
+ upgradeCallback(_assertThisInitialized(_this5));
6907
+ } else {
6908
+ // keep track of elements that were not created by lwc.createElement,
6909
+ // so we can ignore their lifecycle hooks
6910
+ elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this5)); // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
6911
+ // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
6912
+ }
6913
+
6914
+ return _this5;
6915
+ }
6916
+
6917
+ _createClass(UpgradableConstructor, [{
6918
+ key: "connectedCallback",
6919
+ value: function connectedCallback() {
6920
+ if (!elementsUpgradedOutsideLWC.has(this)) {
6921
+ _connectedCallback(this);
6922
+ }
6923
+ }
6924
+ }, {
6925
+ key: "disconnectedCallback",
6926
+ value: function disconnectedCallback() {
6927
+ if (!elementsUpgradedOutsideLWC.has(this)) {
6928
+ _disconnectedCallback(this);
6929
+ }
6930
+ }
6931
+ }]);
6932
+
6933
+ return UpgradableConstructor;
6934
+ }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
6935
+ };
6936
+
6937
+ var createCustomElementVanilla = function createCustomElementVanilla(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
6938
+ // use global custom elements registry
6939
+ var UpgradableConstructor = cachedConstructors.get(tagName);
6940
+
6941
+ if (isUndefined$1(UpgradableConstructor)) {
6942
+ if (!isUndefined$1(customElements.get(tagName))) {
6943
+ throw new Error("Unexpected tag name \"".concat(tagName, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
6944
+ }
6945
+
6946
+ UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
6947
+ customElements.define(tagName, UpgradableConstructor);
6948
+ cachedConstructors.set(tagName, UpgradableConstructor);
6949
+ }
6950
+
6951
+ elementBeingUpgradedByLWC = true;
6952
+
6953
+ try {
6954
+ return new UpgradableConstructor(upgradeCallback);
6955
+ } finally {
6956
+ elementBeingUpgradedByLWC = false;
6957
+ }
6958
+ };
6959
+ /*
6960
+ * Copyright (c) 2020, salesforce.com, inc.
6961
+ * All rights reserved.
6962
+ * SPDX-License-Identifier: MIT
6963
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6964
+ */
6965
+
6966
+ /**
6967
+ * Create a scoped registry, i.e. a function that can create custom elements whose tag names
6968
+ * do not conflict with vanilla custom elements having the same tag name.
6969
+ */
6970
+
6971
+
6972
+ function createScopedRegistry() {
6973
+ if (!hasCustomElements) {
6974
+ // This code should never be reached, because we don't use the pivot registry if
6975
+ // custom elements are unavailable.
6976
+ throw new Error('Custom elements are not supported in this environment.');
6977
+ }
6978
+
6979
+ var _window = window,
6980
+ NativeHTMLElement = _window.HTMLElement;
6981
+ var _NativeHTMLElement$pr = NativeHTMLElement.prototype,
6982
+ nativeHasAttribute = _NativeHTMLElement$pr.hasAttribute,
6983
+ nativeSetAttribute = _NativeHTMLElement$pr.setAttribute,
6984
+ nativeRemoveAttribute = _NativeHTMLElement$pr.removeAttribute,
6985
+ nativeGetAttribute = _NativeHTMLElement$pr.getAttribute;
6986
+ var definitionForElement = new WeakMap();
6987
+ var pendingRegistryForElement = new WeakMap();
6988
+ var definitionForConstructor = new WeakMap();
6989
+ var registeredUserCtors = new WeakSet();
6990
+ var pivotCtorByTag = new Map();
6991
+ var globalDefinitionsByTag = new Map();
6992
+ var globalDefinitionsByClass = new Map();
6993
+ var awaitingUpgrade = new Map();
6994
+ var EMPTY_SET = new Set();
6995
+
6996
+ function createDefinitionRecord(constructor) {
6997
+ var _a;
6998
+
6999
+ var _constructor$prototyp = constructor.prototype,
7000
+ connectedCallback = _constructor$prototyp.connectedCallback,
7001
+ disconnectedCallback = _constructor$prototyp.disconnectedCallback,
7002
+ adoptedCallback = _constructor$prototyp.adoptedCallback,
7003
+ attributeChangedCallback = _constructor$prototyp.attributeChangedCallback;
7004
+ var observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
7005
+ return {
7006
+ UserCtor: constructor,
7007
+ PivotCtor: undefined,
7008
+ connectedCallback: connectedCallback,
7009
+ disconnectedCallback: disconnectedCallback,
7010
+ adoptedCallback: adoptedCallback,
7011
+ attributeChangedCallback: attributeChangedCallback,
7012
+ observedAttributes: observedAttributes
7013
+ };
7014
+ } // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
7015
+ // element. Note that the `registeredDefinition` represents the constructor that was used to register during
7016
+ // `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
7017
+ // constructor is invoked with another constructor.
7018
+
7019
+
7020
+ function createPivotingClass(tagName, registeredDefinition) {
7021
+ var PivotCtor = /*#__PURE__*/function (_NativeHTMLElement) {
7022
+ _inherits(PivotCtor, _NativeHTMLElement);
7023
+
7024
+ var _super8 = _createSuper(PivotCtor);
7025
+
7026
+ function PivotCtor(UserCtor) {
7027
+ var _this6;
7028
+
7029
+ _classCallCheck(this, PivotCtor);
7030
+
7031
+ // This constructor can only be invoked by:
7032
+ // a) the browser instantiating an element from parsing or via document.createElement.
7033
+ // b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
7034
+ // b) new UserClass.
7035
+ // When LWC instantiates it, it will pass the upgrading definition as an argument
7036
+ // If the caller signals via UserCtor that this is in fact a controlled
7037
+ // definition, we use that one, otherwise fallback to the global
7038
+ // internal registry.
7039
+ _this6 = _super8.call(this);
7040
+ var userCtorIsDefined = !isUndefined$1(UserCtor);
7041
+
7042
+ if (userCtorIsDefined) {
7043
+ if (!isConstructor(UserCtor)) {
7044
+ throw new TypeError("Failed to create custom element: the provided constructor is not a constructor.");
7045
+ }
7046
+
7047
+ if (!registeredUserCtors.has(UserCtor)) {
7048
+ throw new Error("Failed to create custom element: the provided constructor is unregistered: ".concat(UserCtor.name, "."));
7049
+ }
7050
+ }
7051
+
7052
+ var definition = userCtorIsDefined ? getOrCreateDefinitionForConstructor(UserCtor) : globalDefinitionsByTag.get(tagName);
7053
+
7054
+ if (!isUndefined$1(definition)) {
7055
+ internalUpgrade(_assertThisInitialized(_this6), registeredDefinition, definition);
7056
+ } else {
7057
+ // This is the case in which there is no global definition, and
7058
+ // it is not handled by LWC (otherwise it will have a valid UserCtor)
7059
+ // so we need to add it to the pending queue just in case it eventually
7060
+ // gets defined in the global registry.
7061
+ pendingRegistryForElement.set(_assertThisInitialized(_this6), registeredDefinition);
7062
+ }
7063
+
7064
+ return _this6;
7065
+ }
7066
+
7067
+ _createClass(PivotCtor, [{
7068
+ key: "connectedCallback",
7069
+ value: function connectedCallback() {
7070
+ var _a;
7071
+
7072
+ var definition = definitionForElement.get(this);
7073
+
7074
+ if (!isUndefined$1(definition)) {
7075
+ // Delegate out to user callback
7076
+ (_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
7077
+ } else {
7078
+ // Register for upgrade when defined (only when connected, so we don't leak)
7079
+ var awaiting = awaitingUpgrade.get(tagName);
7080
+
7081
+ if (isUndefined$1(awaiting)) {
7082
+ awaitingUpgrade.set(tagName, awaiting = new Set());
7083
+ }
7084
+
7085
+ awaiting.add(this);
7086
+ }
7087
+ }
7088
+ }, {
7089
+ key: "disconnectedCallback",
7090
+ value: function disconnectedCallback() {
7091
+ var _a;
7092
+
7093
+ var definition = definitionForElement.get(this);
7094
+
7095
+ if (!isUndefined$1(definition)) {
7096
+ // Delegate out to user callback
7097
+ (_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
7098
+ } else {
7099
+ // Un-register for upgrade when defined (so we don't leak)
7100
+ var awaiting = awaitingUpgrade.get(tagName); // At this point, awaiting should never be undefined, because connectedCallback
7101
+ // must have been called before disconnectedCallback. But just to be safe, we check
7102
+
7103
+ if (!isUndefined$1(awaiting)) {
7104
+ awaiting.delete(this);
7105
+ }
7106
+ }
7107
+ }
7108
+ }, {
7109
+ key: "adoptedCallback",
7110
+ value: function adoptedCallback() {
7111
+ var _a;
7112
+
7113
+ var definition = definitionForElement.get(this);
7114
+ (_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
7115
+ }
7116
+ }, {
7117
+ key: "attributeChangedCallback",
7118
+ value: function attributeChangedCallback(name, oldValue, newValue) {
7119
+ var _a;
7120
+
7121
+ var definition = definitionForElement.get(this); // if both definitions are the same, then the observedAttributes is the same,
7122
+ // but if they are different, only if the runtime definition has the attribute
7123
+ // marked as observed, then it should invoke attributeChangedCallback.
7124
+
7125
+ if (registeredDefinition === definition || (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
7126
+ (_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
7127
+ }
7128
+ }
7129
+ }]);
7130
+
7131
+ return PivotCtor;
7132
+ }(NativeHTMLElement);
7133
+
7134
+ PivotCtor.observedAttributes = _toConsumableArray(registeredDefinition.observedAttributes);
7135
+ return PivotCtor;
7136
+ }
7137
+
7138
+ function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
7139
+ var observedAttributes = pivotDefinition.observedAttributes,
7140
+ attributeChangedCallback = pivotDefinition.attributeChangedCallback;
7141
+
7142
+ if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
7143
+ // This instance does not need to observe any attributes, no need to patch
7144
+ return EMPTY_SET;
7145
+ } // Natively, the attributes observed by the registered definition are going to be taken
7146
+ // care of by the browser, only the difference between the two sets has to be taken
7147
+ // care by the patched version.
7148
+
7149
+
7150
+ return new Set(_toConsumableArray(pivotDefinition.observedAttributes).filter(function (x) {
7151
+ return !registeredDefinition.observedAttributes.has(x);
7152
+ }));
7153
+ }
7154
+
7155
+ function throwAsyncError(error) {
7156
+ // Per native custom element behavior, errors thrown in attributeChangedCallback
7157
+ // become unhandled async errors. We use setTimeout() instead of Promise.resolve()
7158
+ // to make it an unhandled error rather than an unhandled rejection.
7159
+ setTimeout(function () {
7160
+ throw error;
7161
+ });
7162
+ } // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
7163
+ // Why is this necessary? Well basically, you can't change the `observedAttributes` after
7164
+ // a custom element is defined. So with pivots, if two classes share the same tag name,
7165
+ // and the second class observes attributes that aren't observed by the first one,
7166
+ // then those attributes can never be observed by the native `observedAttributes` system.
7167
+ // So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
7168
+ // we only do this when absolutely necessary, though; i.e. because we've determined
7169
+ // that we aren't observing the attributes we need to.
7170
+
7171
+
7172
+ function patchAttributes(instance, registeredDefinition, pivotDefinition) {
7173
+ var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
7174
+
7175
+ if (newObservedAttributes.size === 0) {
7176
+ return;
7177
+ }
7178
+
7179
+ var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Patch the instance.
7180
+ // Note we use the native `getAttribute` rather than the super's `getAttribute` because
7181
+ // we don't actually want it to be observable that we're calling `getAttribute` from
7182
+ // `setAttribute` and `removeAttribute`.
7183
+ // TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
7184
+
7185
+ defineProperties(instance, {
7186
+ setAttribute: {
7187
+ value: function setAttribute(name, value) {
7188
+ if (newObservedAttributes.has(name)) {
7189
+ var old = nativeGetAttribute.call(this, name);
7190
+ nativeSetAttribute.call(this, name, value);
7191
+
7192
+ try {
7193
+ attributeChangedCallback.call(this, name, old, value + '');
7194
+ } catch (error) {
7195
+ throwAsyncError(error);
7196
+ }
7197
+ } else {
7198
+ nativeSetAttribute.call(this, name, value);
7199
+ }
7200
+ },
7201
+ writable: true,
7202
+ enumerable: true,
7203
+ configurable: true
7204
+ },
7205
+ removeAttribute: {
7206
+ value: function removeAttribute(name) {
7207
+ if (newObservedAttributes.has(name)) {
7208
+ var old = nativeGetAttribute.call(this, name);
7209
+ nativeRemoveAttribute.call(this, name);
7210
+
7211
+ try {
7212
+ attributeChangedCallback.call(this, name, old, null);
7213
+ } catch (error) {
7214
+ throwAsyncError(error);
7215
+ }
7216
+ } else {
7217
+ nativeRemoveAttribute.call(this, name);
7218
+ }
7219
+ },
7220
+ writable: true,
7221
+ enumerable: true,
7222
+ configurable: true
7223
+ }
7224
+ });
7225
+ }
7226
+
7227
+ function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
7228
+ // The below case patches observed attributes for the case where the HTML element is upgraded
7229
+ // from a pre-existing one in the DOM.
7230
+ var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
7231
+
7232
+ if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
7233
+ return;
7234
+ }
7235
+
7236
+ var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Approximate observedAttributes from the user class, but only for the new observed attributes
7237
+
7238
+ newObservedAttributes.forEach(function (name) {
7239
+ if (nativeHasAttribute.call(instance, name)) {
7240
+ var newValue = nativeGetAttribute.call(instance, name);
7241
+ attributeChangedCallback.call(instance, name, null, newValue);
7242
+ }
7243
+ });
7244
+ } // User extends this HTMLElement, which returns the CE being upgraded
7245
+
7246
+
7247
+ var upgradingInstance; // Helper to upgrade an instance with a CE definition using "constructor call trick"
7248
+
7249
+ function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
7250
+ setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
7251
+ definitionForElement.set(instance, pivotDefinition); // attributes patches when needed
7252
+
7253
+ if (pivotDefinition !== registeredDefinition) {
7254
+ patchAttributes(instance, registeredDefinition, pivotDefinition);
7255
+ } // Tricking the construction path to believe that a new instance is being created,
7256
+ // that way it will execute the super initialization mechanism but the HTMLElement
7257
+ // constructor will reuse the instance by returning the upgradingInstance.
7258
+ // This is by far the most important piece of the puzzle
7259
+
7260
+
7261
+ upgradingInstance = instance; // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
7262
+ // The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
7263
+ // Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
7264
+
7265
+ new pivotDefinition.UserCtor();
7266
+ patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
7267
+ }
7268
+
7269
+ function isConstructor(constructor) {
7270
+ return isFunction$1(constructor) && isObject(constructor.prototype);
7271
+ }
7272
+
7273
+ function getOrCreateDefinitionForConstructor(constructor) {
7274
+ if (!isConstructor(constructor)) {
7275
+ throw new TypeError('The referenced constructor is not a constructor.');
7276
+ }
7277
+
7278
+ var definition = definitionForConstructor.get(constructor);
7279
+
7280
+ if (!isUndefined$1(definition)) {
7281
+ return definition;
7282
+ }
7283
+
7284
+ return createDefinitionRecord(constructor);
7285
+ }
7286
+
7287
+ var _window2 = window,
7288
+ nativeRegistry = _window2.customElements;
7289
+ var nativeDefine = nativeRegistry.define,
7290
+ nativeWhenDefined = nativeRegistry.whenDefined,
7291
+ nativeGet = nativeRegistry.get; // patch for the global registry define mechanism
7292
+
7293
+ CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
7294
+ if (options && options.extends) {
7295
+ // TODO [#2983]: should we support `extends`?
7296
+ throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
7297
+ }
7298
+
7299
+ if (globalDefinitionsByTag.has(tagName)) {
7300
+ throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"".concat(tagName, "\" has already been used with this registry"));
7301
+ }
7302
+
7303
+ if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
7304
+ throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");
7305
+ }
7306
+
7307
+ var definition = getOrCreateDefinitionForConstructor(constructor);
7308
+ registeredUserCtors.add(constructor);
7309
+ var PivotCtor = pivotCtorByTag.get(tagName);
7310
+
7311
+ if (isUndefined$1(PivotCtor)) {
7312
+ PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class which will handle global registry initializations
7313
+
7314
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
7315
+ } // Only cache after nativeDefine has been called, because if it throws an error
7316
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
7317
+
7318
+
7319
+ definitionForConstructor.set(constructor, definition);
7320
+ pivotCtorByTag.set(tagName, PivotCtor);
7321
+ globalDefinitionsByTag.set(tagName, definition);
7322
+ globalDefinitionsByClass.set(constructor, definition); // For globally defined custom elements, the definition associated
7323
+ // to the UserCtor has a back-pointer to PivotCtor in case the user
7324
+ // new the UserCtor, so we know how to create the underlying element.
7325
+
7326
+ definition.PivotCtor = PivotCtor; // Upgrade any elements created in this scope before customElements.define
7327
+ // was called, which should be exhibited by the following steps:
7328
+ // 1) LWC registers a tagName for an LWC component.
7329
+ // 2) Element with same tagName is created with document.createElement()
7330
+ // and inserted into DOM.
7331
+ // 3) customElements.define() is called with tagName and non-LWC constructor.
7332
+ // This requires immediate upgrade when the new global tagName is defined.
7333
+
7334
+ var awaiting = awaitingUpgrade.get(tagName);
7335
+
7336
+ if (!isUndefined$1(awaiting)) {
7337
+ awaitingUpgrade.delete(tagName);
7338
+
7339
+ var _iterator6 = _createForOfIteratorHelper(awaiting),
7340
+ _step6;
7341
+
7342
+ try {
7343
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
7344
+ var element = _step6.value;
7345
+ var registeredDefinition = pendingRegistryForElement.get(element); // At this point, registeredDefinition should never be undefined because awaitingUpgrade
7346
+ // is only populated when we haven't run internalUpgrade yet, and we only populate
7347
+ // pendingRegistryForElement when internalUpgrade hasn't run yet.
7348
+ // But just to be safe, we check.
7349
+
7350
+ if (!isUndefined$1(registeredDefinition)) {
7351
+ pendingRegistryForElement.delete(element);
7352
+ internalUpgrade(element, registeredDefinition, definition);
7353
+ }
7354
+ }
7355
+ } catch (err) {
7356
+ _iterator6.e(err);
7357
+ } finally {
7358
+ _iterator6.f();
7359
+ }
7360
+ }
7361
+ };
7362
+
7363
+ CustomElementRegistry.prototype.get = function get(tagName) {
7364
+ var NativeCtor = nativeGet.call(nativeRegistry, tagName);
7365
+
7366
+ if (!isUndefined$1(NativeCtor)) {
7367
+ var definition = globalDefinitionsByTag.get(tagName);
7368
+
7369
+ if (!isUndefined$1(definition)) {
7370
+ return definition.UserCtor; // defined by the patched custom elements registry
7371
+ } // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7372
+
7373
+
7374
+ return NativeCtor; // return the pivot constructor or constructor that existed before patching
7375
+ }
7376
+ };
7377
+
7378
+ CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
7379
+ return nativeWhenDefined.call(nativeRegistry, tagName).then(function (NativeCtor) {
7380
+ var definition = globalDefinitionsByTag.get(tagName);
7381
+
7382
+ if (!isUndefined$1(definition)) {
7383
+ return definition.UserCtor;
7384
+ } // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
7385
+ // In this case, the custom element must have been defined before the registry patches
7386
+ // were applied. So return the non-pivot constructor
7387
+
7388
+
7389
+ if (isUndefined$1(NativeCtor)) {
7390
+ // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
7391
+ // We can patch the correct behavior using customElements.get()
7392
+ return nativeGet.call(nativeRegistry, tagName);
7393
+ }
7394
+
7395
+ return NativeCtor;
7396
+ });
7397
+ }; // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
7398
+ // @ts-ignore
7399
+
7400
+
7401
+ window.HTMLElement = function HTMLElement() {
7402
+ // Upgrading case: the pivoting class constructor was run by the browser's
7403
+ // native custom elements and we're in the process of running the
7404
+ // "constructor-call trick" on the natively constructed instance, so just
7405
+ // return that here.
7406
+ // This code path is also called when LWC `new`s a PivotCtor.
7407
+ var instance = upgradingInstance;
7408
+
7409
+ if (!isUndefined$1(instance)) {
7410
+ upgradingInstance = undefined;
7411
+ return instance;
7412
+ } // Construction case: we need to construct the pivoting instance and return it.
7413
+ // This is possible when the user register it via global registry and instantiate
7414
+ // it via `new Ctor()`.
7415
+
7416
+
7417
+ var constructor = this.constructor;
7418
+ var definition = globalDefinitionsByClass.get(constructor);
7419
+
7420
+ if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
7421
+ // This code path is hit if someone `new`s a class that extends `HTMLElement` without
7422
+ // doing `customElements.define()` first. This matches native browser behavior:
7423
+ // https://stackoverflow.com/a/61883392
7424
+ throw new TypeError('Illegal constructor');
7425
+ } // This constructor is ONLY invoked when it is the user instantiating
7426
+ // an element via new Ctor while Ctor is a registered global constructor.
7427
+
7428
+
7429
+ var PivotCtor = definition.PivotCtor,
7430
+ UserCtor = definition.UserCtor;
7431
+ return new PivotCtor(UserCtor);
7432
+ };
7433
+
7434
+ HTMLElement.prototype = NativeHTMLElement.prototype;
7435
+ /**
7436
+ * Create a new PivotConstructor for the given tagName, which is capable of being constructed
7437
+ * with a UserConstructor defining the behavior. Passing in the UserConstructor here
7438
+ * is a hint that can be used when registering a custom element with the global custom elements
7439
+ * registry for the first time, which provides certain optimizations. It also marks the UserConstructor
7440
+ * as "safe" to be used when passed in to a PivotConstructor.
7441
+ *
7442
+ * @param tagName - element tag name
7443
+ * @param UserCtor - userland custom element constructor
7444
+ * @returns a new custom element constructor
7445
+ */
7446
+
7447
+ return function createPivotConstructor(tagName, UserCtor) {
7448
+ tagName = StringToLowerCase.call(tagName);
7449
+ var PivotCtor = pivotCtorByTag.get(tagName);
7450
+
7451
+ if (isUndefined$1(PivotCtor)) {
7452
+ var definition = getOrCreateDefinitionForConstructor(UserCtor);
7453
+ PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class as a global custom element
7454
+
7455
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
7456
+ definition.PivotCtor = PivotCtor; // Only cache after nativeDefine has been called, because if it throws an error
7457
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
7458
+
7459
+ definitionForConstructor.set(UserCtor, definition);
7460
+ pivotCtorByTag.set(tagName, PivotCtor);
7461
+ } // Register a UserConstructor as "safe" to be used within a PivotConstructor
7462
+
7463
+
7464
+ registeredUserCtors.add(UserCtor);
7465
+ return PivotCtor;
7466
+ };
7467
+ }
7468
+ /*
7469
+ * Copyright (c) 2018, salesforce.com, inc.
7470
+ * All rights reserved.
7471
+ * SPDX-License-Identifier: MIT
7472
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7473
+ */
7474
+
7475
+
7476
+ var createScopedConstructor;
7477
+ var CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
7478
+ // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
7479
+ // or we're in a legacy browser.
7480
+
7481
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
7482
+ if (hasCustomElements) {
7483
+ // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
7484
+ // It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
7485
+ //
7486
+ // Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
7487
+ //
7488
+ // 1. LWC loads
7489
+ // 2. `const Ctor = class extends HTMLElement {}`
7490
+ // 3. `lwc.createElement(...)` // here we lazily patch
7491
+ // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
7492
+ //
7493
+ // To reduce the risk of this, it's safer to patch the registry eagerly.
7494
+ createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
7495
+ // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
7496
+ // because the HTMLElement prototypes are mixed up.
7497
+ //
7498
+ // The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
7499
+ // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
7500
+ // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
7501
+ // Caching avoids this problem.
7502
+
7503
+ CachedHTMLElement = window.HTMLElement;
7504
+ }
7505
+ } // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
7506
+ // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
7507
+ // multiple times per tag name.
7508
+
7509
+
7510
+ var createUserConstructor = function createUserConstructor(upgradeCallback, _connectedCallback2, _disconnectedCallback2, HTMLElementToExtend) {
7511
+ // TODO [#2972]: this class should expose observedAttributes as necessary
7512
+ return /*#__PURE__*/function (_HTMLElementToExtend) {
7513
+ _inherits(UserConstructor, _HTMLElementToExtend);
7514
+
7515
+ var _super9 = _createSuper(UserConstructor);
7516
+
7517
+ function UserConstructor() {
7518
+ var _this7;
7519
+
7520
+ _classCallCheck(this, UserConstructor);
7521
+
7522
+ _this7 = _super9.call(this);
7523
+ upgradeCallback(_assertThisInitialized(_this7));
7524
+ return _this7;
7525
+ }
7526
+
7527
+ _createClass(UserConstructor, [{
7528
+ key: "connectedCallback",
7529
+ value: function connectedCallback() {
7530
+ _connectedCallback2(this);
7531
+ }
7532
+ }, {
7533
+ key: "disconnectedCallback",
7534
+ value: function disconnectedCallback() {
7535
+ _disconnectedCallback2(this);
7536
+ }
7537
+ }]);
7538
+
7539
+ return UserConstructor;
7540
+ }(HTMLElementToExtend);
7541
+ };
7542
+
7543
+ function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
7544
+ if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
7545
+ // This error should be impossible to hit
7546
+ throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
7547
+ }
7548
+
7549
+ var UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
7550
+ var ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
7551
+ return new ScopedConstructor(UserConstructor);
7552
+ }
7553
+ /*
7554
+ * Copyright (c) 2018, salesforce.com, inc.
7555
+ * All rights reserved.
7556
+ * SPDX-License-Identifier: MIT
7557
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7558
+ */
7559
+
7560
+ /**
7561
+ * We have three modes for creating custom elements:
7562
+ *
7563
+ * 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
7564
+ * 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
7565
+ * same tag name, via a simple trick: every custom element constructor we define in the registry is basically
7566
+ * the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
7567
+ * constructor, which allows us to have completely customized functionality for different components.
7568
+ * 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
7569
+ * elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
7570
+ * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
7571
+ * because it must patch the global `customElements` and `HTMLElement` objects.
7572
+ */
7573
+
7574
+
7575
+ var createCustomElement;
7576
+
7577
+ if (hasCustomElements) {
7578
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
7579
+ createCustomElement = createCustomElementScoped;
7580
+ } else {
7581
+ // use global custom elements registry (vanilla)
7582
+ createCustomElement = createCustomElementVanilla;
7583
+ }
7584
+ } else {
7585
+ // no registry available here
7586
+ createCustomElement = createCustomElementCompat;
7587
+ }
6855
7588
  /*
6856
7589
  * Copyright (c) 2018, salesforce.com, inc.
6857
7590
  * All rights reserved.
@@ -6920,7 +7653,7 @@ var LWC = (function (exports) {
6920
7653
  function isNull(obj) {
6921
7654
  return obj === null;
6922
7655
  }
6923
- /** version: 2.25.0 */
7656
+ /** version: 2.26.0 */
6924
7657
 
6925
7658
  /*
6926
7659
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6930,87 +7663,6 @@ var LWC = (function (exports) {
6930
7663
  */
6931
7664
 
6932
7665
 
6933
- exports.getCustomElement = void 0;
6934
- exports.defineCustomElement = void 0;
6935
- var HTMLElementConstructor;
6936
-
6937
- function isCustomElementRegistryAvailable() {
6938
- if (typeof customElements === 'undefined') {
6939
- return false;
6940
- }
6941
-
6942
- try {
6943
- // dereference HTMLElement global because babel wraps globals in compat mode with a
6944
- // _wrapNativeSuper()
6945
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
6946
- // get wrapped by babel.
6947
- var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
6948
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
6949
- // which are not equipped to be initialized that way.
6950
-
6951
- var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
6952
- _inherits(clazz, _HTMLElementAlias);
6953
-
6954
- var _super7 = _createSuper(clazz);
6955
-
6956
- function clazz() {
6957
- _classCallCheck(this, clazz);
6958
-
6959
- return _super7.apply(this, arguments);
6960
- }
6961
-
6962
- return _createClass(clazz);
6963
- }(HTMLElementAlias);
6964
-
6965
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
6966
- new clazz();
6967
- return true;
6968
- } catch (_a) {
6969
- return false;
6970
- }
6971
- }
6972
-
6973
- if (isCustomElementRegistryAvailable()) {
6974
- exports.getCustomElement = customElements.get.bind(customElements);
6975
- exports.defineCustomElement = customElements.define.bind(customElements);
6976
- HTMLElementConstructor = HTMLElement;
6977
- } else {
6978
- var registry = Object.create(null);
6979
- var reverseRegistry = new WeakMap();
6980
-
6981
- exports.defineCustomElement = function define(name, ctor) {
6982
- if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
6983
- throw new TypeError("Invalid Registration");
6984
- }
6985
-
6986
- registry[name] = ctor;
6987
- reverseRegistry.set(ctor, name);
6988
- };
6989
-
6990
- exports.getCustomElement = function get(name) {
6991
- return registry[name];
6992
- };
6993
-
6994
- HTMLElementConstructor = function HTMLElement() {
6995
- if (!(this instanceof HTMLElement)) {
6996
- throw new TypeError("Invalid Invocation");
6997
- }
6998
-
6999
- var constructor = this.constructor;
7000
- var name = reverseRegistry.get(constructor);
7001
-
7002
- if (!name) {
7003
- throw new TypeError("Invalid Construction");
7004
- }
7005
-
7006
- var elm = document.createElement(name);
7007
- Object.setPrototypeOf(elm, constructor.prototype);
7008
- return elm;
7009
- };
7010
-
7011
- HTMLElementConstructor.prototype = HTMLElement.prototype;
7012
- }
7013
-
7014
7666
  function cloneNode(node, deep) {
7015
7667
  return node.cloneNode(deep);
7016
7668
  }
@@ -7069,18 +7721,18 @@ var LWC = (function (exports) {
7069
7721
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
7070
7722
 
7071
7723
  if (!isUndefined(wrapperTags)) {
7072
- var _iterator6 = _createForOfIteratorHelper(wrapperTags),
7073
- _step6;
7724
+ var _iterator7 = _createForOfIteratorHelper(wrapperTags),
7725
+ _step7;
7074
7726
 
7075
7727
  try {
7076
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
7077
- var wrapperTag = _step6.value;
7728
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
7729
+ var wrapperTag = _step7.value;
7078
7730
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
7079
7731
  }
7080
7732
  } catch (err) {
7081
- _iterator6.e(err);
7733
+ _iterator7.e(err);
7082
7734
  } finally {
7083
- _iterator6.f();
7735
+ _iterator7.f();
7084
7736
  }
7085
7737
  } // For IE11, the document title must not be undefined, but it can be an empty string
7086
7738
  // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
@@ -7226,8 +7878,6 @@ var LWC = (function (exports) {
7226
7878
  assert.invariant(elm instanceof HTMLElement, msg);
7227
7879
  }
7228
7880
 
7229
- var HTMLElementExported = HTMLElementConstructor;
7230
- exports.HTMLElementExported = HTMLElementExported;
7231
7881
  exports.addEventListener = addEventListener;
7232
7882
  exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
7233
7883
  exports.attachShadow = attachShadow;
@@ -7286,6 +7936,8 @@ var LWC = (function (exports) {
7286
7936
  {
7287
7937
  // insertStyleSheet implementation shares a global cache of stylesheet data
7288
7938
  insertStylesheet: insertStylesheet,
7939
+ // relies on a shared global cache
7940
+ createCustomElement: createCustomElement,
7289
7941
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7290
7942
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
7291
7943
  });
@@ -7402,35 +8054,39 @@ var LWC = (function (exports) {
7402
8054
  var hydratedCustomElements = new WeakSet();
7403
8055
 
7404
8056
  function buildCustomElementConstructor(Ctor) {
8057
+ var _a;
8058
+
7405
8059
  var HtmlPrototype = getComponentHtmlPrototype(Ctor);
7406
- return /*#__PURE__*/function (_HtmlPrototype) {
7407
- _inherits(_class, _HtmlPrototype);
8060
+ var observedAttributes = HtmlPrototype.observedAttributes;
8061
+ var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
8062
+ return _a = /*#__PURE__*/function (_HTMLElement2) {
8063
+ _inherits(_a, _HTMLElement2);
7408
8064
 
7409
- var _super8 = _createSuper(_class);
8065
+ var _super10 = _createSuper(_a);
7410
8066
 
7411
- function _class() {
7412
- var _this6;
8067
+ function _a() {
8068
+ var _this8;
7413
8069
 
7414
- _classCallCheck(this, _class);
8070
+ _classCallCheck(this, _a);
7415
8071
 
7416
- _this6 = _super8.call(this);
8072
+ _this8 = _super10.call(this);
7417
8073
 
7418
- if (_this6.isConnected) {
8074
+ if (_this8.isConnected) {
7419
8075
  // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
7420
- hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
7421
- hydratedCustomElements.add(_assertThisInitialized(_this6));
8076
+ hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
8077
+ hydratedCustomElements.add(_assertThisInitialized(_this8));
7422
8078
  } else {
7423
- createVM(_assertThisInitialized(_this6), Ctor, renderer, {
8079
+ createVM(_assertThisInitialized(_this8), Ctor, renderer, {
7424
8080
  mode: 'open',
7425
8081
  owner: null,
7426
- tagName: _this6.tagName
8082
+ tagName: _this8.tagName
7427
8083
  });
7428
8084
  }
7429
8085
 
7430
- return _this6;
8086
+ return _this8;
7431
8087
  }
7432
8088
 
7433
- _createClass(_class, [{
8089
+ _createClass(_a, [{
7434
8090
  key: "connectedCallback",
7435
8091
  value: function connectedCallback() {
7436
8092
  if (hydratedCustomElements.has(this)) {
@@ -7445,10 +8101,15 @@ var LWC = (function (exports) {
7445
8101
  value: function disconnectedCallback() {
7446
8102
  disconnectRootElement(this);
7447
8103
  }
8104
+ }, {
8105
+ key: "attributeChangedCallback",
8106
+ value: function attributeChangedCallback(name, oldValue, newValue) {
8107
+ _attributeChangedCallback.call(this, name, oldValue, newValue);
8108
+ }
7448
8109
  }]);
7449
8110
 
7450
- return _class;
7451
- }(HtmlPrototype);
8111
+ return _a;
8112
+ }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)), _a.observedAttributes = observedAttributes, _a;
7452
8113
  }
7453
8114
  /*
7454
8115
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7531,8 +8192,11 @@ var LWC = (function (exports) {
7531
8192
  throw new TypeError("\"createElement\" function expects an \"is\" option with a valid component constructor.");
7532
8193
  }
7533
8194
 
7534
- var UpgradableConstructor = getUpgradableConstructor(sel, renderer);
7535
- var wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
8195
+ var createCustomElement = renderer.createCustomElement; // tagName must be all lowercase, unfortunately, we have legacy code that is
8196
+ // passing `sel` as a camel-case, which makes them invalid custom elements name
8197
+ // the following line guarantees that this does not leaks beyond this point.
8198
+
8199
+ var tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
7536
8200
 
7537
8201
  /**
7538
8202
  * Note: if the upgradable constructor does not expect, or throw when we new it
@@ -7541,9 +8205,9 @@ var LWC = (function (exports) {
7541
8205
  * an upgradable custom element.
7542
8206
  */
7543
8207
 
7544
- var element = new UpgradableConstructor(function (elm) {
8208
+ var upgradeCallback = function upgradeCallback(elm) {
7545
8209
  createVM(elm, Ctor, renderer, {
7546
- tagName: sel,
8210
+ tagName: tagName,
7547
8211
  mode: options.mode !== 'closed' ? 'open' : 'closed',
7548
8212
  owner: null
7549
8213
  });
@@ -7552,15 +8216,21 @@ var LWC = (function (exports) {
7552
8216
  ConnectingSlot.set(elm, connectRootElement);
7553
8217
  DisconnectingSlot.set(elm, disconnectRootElement);
7554
8218
  }
8219
+ };
7555
8220
 
7556
- wasComponentUpgraded = true;
7557
- });
8221
+ var connectedCallback = function connectedCallback(elm) {
8222
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8223
+ connectRootElement(elm);
8224
+ }
8225
+ };
7558
8226
 
7559
- if (!wasComponentUpgraded) {
7560
- /* eslint-disable-next-line no-console */
7561
- console.error("Unexpected tag name \"".concat(sel, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
7562
- }
8227
+ var disconnectedCallback = function disconnectedCallback(elm) {
8228
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8229
+ disconnectRootElement(elm);
8230
+ }
8231
+ };
7563
8232
 
8233
+ var element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
7564
8234
  return element;
7565
8235
  }
7566
8236
  /*
@@ -7643,7 +8313,7 @@ var LWC = (function (exports) {
7643
8313
  });
7644
8314
  freeze(LightningElement);
7645
8315
  seal(LightningElement.prototype);
7646
- /* version: 2.25.0 */
8316
+ /* version: 2.26.0 */
7647
8317
 
7648
8318
  exports.LightningElement = LightningElement;
7649
8319
  exports.__unstable__ProfilerControl = profilerControl;