lwc 2.25.1 → 2.27.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 (37) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +953 -431
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +953 -431
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +797 -223
  5. package/dist/engine-dom/iife/es5/engine-dom.js +1025 -330
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +952 -241
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +953 -431
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +797 -223
  11. package/dist/engine-dom/umd/es5/engine-dom.js +1025 -330
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +952 -241
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +201 -247
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +201 -247
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +4 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4 -4
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
  26. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  28. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  29. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  31. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  37. package/package.json +7 -7
@@ -123,8 +123,10 @@
123
123
  setPrototypeOf = Object.setPrototypeOf;
124
124
  var isArray$1 = Array.isArray;
125
125
  var _Array$prototype = Array.prototype,
126
+ ArrayConcat$1 = _Array$prototype.concat,
126
127
  ArrayCopyWithin = _Array$prototype.copyWithin,
127
128
  ArrayFill = _Array$prototype.fill,
129
+ ArrayFilter = _Array$prototype.filter,
128
130
  ArrayIndexOf = _Array$prototype.indexOf,
129
131
  ArrayJoin = _Array$prototype.join,
130
132
  ArrayMap = _Array$prototype.map,
@@ -368,9 +370,9 @@
368
370
  // Increment whenever the LWC template compiler changes
369
371
 
370
372
 
371
- var LWC_VERSION = "2.25.1";
373
+ var LWC_VERSION = "2.27.0";
372
374
  var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
373
- /** version: 2.25.1 */
375
+ /** version: 2.27.0 */
374
376
 
375
377
  /**
376
378
  * Copyright (C) 2018 salesforce.com, inc.
@@ -464,7 +466,7 @@
464
466
  patch$1(propName);
465
467
  }
466
468
  }
467
- /** version: 2.25.1 */
469
+ /** version: 2.27.0 */
468
470
 
469
471
  /**
470
472
  * Copyright (C) 2018 salesforce.com, inc.
@@ -482,7 +484,6 @@
482
484
  DUMMY_TEST_FLAG: null,
483
485
  ENABLE_ELEMENT_PATCH: null,
484
486
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
485
- ENABLE_HMR: null,
486
487
  ENABLE_HTML_COLLECTIONS_PATCH: null,
487
488
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
488
489
  ENABLE_MIXED_SHADOW_MODE: null,
@@ -492,7 +493,8 @@
492
493
  ENABLE_REACTIVE_SETTER: null,
493
494
  ENABLE_WIRE_SYNC_EMIT: null,
494
495
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
495
- DISABLE_LIGHT_DOM_UNSCOPED_CSS: null
496
+ DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
497
+ ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
496
498
  };
497
499
 
498
500
  if (!_globalThis.lwcRuntimeFlags) {
@@ -558,7 +560,7 @@
558
560
  setFeatureFlag(name, value);
559
561
  }
560
562
  }
561
- /** version: 2.25.1 */
563
+ /** version: 2.27.0 */
562
564
 
563
565
  /*
564
566
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2426,7 +2428,9 @@
2426
2428
  var LightningElement = function LightningElement() {
2427
2429
  // This should be as performant as possible, while any initialization should be done lazily
2428
2430
  if (isNull(vmBeingConstructed)) {
2429
- throw new ReferenceError('Illegal constructor');
2431
+ // Thrown when doing something like `new LightningElement()` or
2432
+ // `class Foo extends LightningElement {}; new Foo()`
2433
+ throw new TypeError('Illegal constructor');
2430
2434
  }
2431
2435
 
2432
2436
  var vm = vmBeingConstructed;
@@ -3790,13 +3794,11 @@
3790
3794
  throw new ReferenceError();
3791
3795
  }
3792
3796
 
3793
- if (lwcRuntimeFlags.ENABLE_HMR) {
3794
- var visited = new Set();
3797
+ var visited = new Set();
3795
3798
 
3796
- while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
3797
- visited.add(tpl);
3798
- tpl = swappedTemplateMap.get(tpl);
3799
- }
3799
+ while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
3800
+ visited.add(tpl);
3801
+ tpl = swappedTemplateMap.get(tpl);
3800
3802
  }
3801
3803
 
3802
3804
  return tpl;
@@ -3808,13 +3810,11 @@
3808
3810
  throw new ReferenceError();
3809
3811
  }
3810
3812
 
3811
- if (lwcRuntimeFlags.ENABLE_HMR) {
3812
- var visited = new Set();
3813
+ var visited = new Set();
3813
3814
 
3814
- while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
3815
- visited.add(Ctor);
3816
- Ctor = swappedComponentMap.get(Ctor);
3817
- }
3815
+ while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
3816
+ visited.add(Ctor);
3817
+ Ctor = swappedComponentMap.get(Ctor);
3818
3818
  }
3819
3819
 
3820
3820
  return Ctor;
@@ -3826,13 +3826,11 @@
3826
3826
  throw new ReferenceError();
3827
3827
  }
3828
3828
 
3829
- if (lwcRuntimeFlags.ENABLE_HMR) {
3830
- var visited = new Set();
3829
+ var visited = new Set();
3831
3830
 
3832
- while (swappedStyleMap.has(style) && !visited.has(style)) {
3833
- visited.add(style);
3834
- style = swappedStyleMap.get(style);
3835
- }
3831
+ while (swappedStyleMap.has(style) && !visited.has(style)) {
3832
+ visited.add(style);
3833
+ style = swappedStyleMap.get(style);
3836
3834
  }
3837
3835
 
3838
3836
  return style;
@@ -3842,56 +3840,54 @@
3842
3840
  if (process.env.NODE_ENV === 'production') {
3843
3841
  // this method should never leak to prod
3844
3842
  throw new ReferenceError();
3845
- }
3843
+ } // tracking active component
3846
3844
 
3847
- if (lwcRuntimeFlags.ENABLE_HMR) {
3848
- // tracking active component
3849
- var Ctor = vm.def.ctor;
3850
- var componentVMs = activeComponents.get(Ctor);
3851
3845
 
3852
- if (isUndefined$1(componentVMs)) {
3853
- componentVMs = new Set();
3854
- activeComponents.set(Ctor, componentVMs);
3855
- } // this will allow us to keep track of the hot components
3846
+ var Ctor = vm.def.ctor;
3847
+ var componentVMs = activeComponents.get(Ctor);
3856
3848
 
3849
+ if (isUndefined$1(componentVMs)) {
3850
+ componentVMs = new Set();
3851
+ activeComponents.set(Ctor, componentVMs);
3852
+ } // this will allow us to keep track of the hot components
3857
3853
 
3858
- componentVMs.add(vm); // tracking active template
3859
3854
 
3860
- var tpl = vm.cmpTemplate;
3855
+ componentVMs.add(vm); // tracking active template
3861
3856
 
3862
- if (tpl) {
3863
- var templateVMs = activeTemplates.get(tpl);
3857
+ var tpl = vm.cmpTemplate;
3864
3858
 
3865
- if (isUndefined$1(templateVMs)) {
3866
- templateVMs = new Set();
3867
- activeTemplates.set(tpl, templateVMs);
3868
- } // this will allow us to keep track of the templates that are
3869
- // being used by a hot component
3859
+ if (tpl) {
3860
+ var templateVMs = activeTemplates.get(tpl);
3870
3861
 
3862
+ if (isUndefined$1(templateVMs)) {
3863
+ templateVMs = new Set();
3864
+ activeTemplates.set(tpl, templateVMs);
3865
+ } // this will allow us to keep track of the templates that are
3866
+ // being used by a hot component
3871
3867
 
3872
- templateVMs.add(vm); // tracking active styles associated to template
3873
3868
 
3874
- var stylesheets = tpl.stylesheets;
3869
+ templateVMs.add(vm); // tracking active styles associated to template
3875
3870
 
3876
- if (!isUndefined$1(stylesheets)) {
3877
- flattenStylesheets(stylesheets).forEach(function (stylesheet) {
3878
- // this is necessary because we don't hold the list of styles
3879
- // in the vm, we only hold the selected (already swapped template)
3880
- // but the styles attached to the template might not be the actual
3881
- // active ones, but the swapped versions of those.
3882
- stylesheet = getStyleOrSwappedStyle(stylesheet);
3883
- var stylesheetVMs = activeStyles.get(stylesheet);
3871
+ var stylesheets = tpl.stylesheets;
3884
3872
 
3885
- if (isUndefined$1(stylesheetVMs)) {
3886
- stylesheetVMs = new Set();
3887
- activeStyles.set(stylesheet, stylesheetVMs);
3888
- } // this will allow us to keep track of the stylesheet that are
3889
- // being used by a hot component
3873
+ if (!isUndefined$1(stylesheets)) {
3874
+ flattenStylesheets(stylesheets).forEach(function (stylesheet) {
3875
+ // this is necessary because we don't hold the list of styles
3876
+ // in the vm, we only hold the selected (already swapped template)
3877
+ // but the styles attached to the template might not be the actual
3878
+ // active ones, but the swapped versions of those.
3879
+ stylesheet = getStyleOrSwappedStyle(stylesheet);
3880
+ var stylesheetVMs = activeStyles.get(stylesheet);
3890
3881
 
3882
+ if (isUndefined$1(stylesheetVMs)) {
3883
+ stylesheetVMs = new Set();
3884
+ activeStyles.set(stylesheet, stylesheetVMs);
3885
+ } // this will allow us to keep track of the stylesheet that are
3886
+ // being used by a hot component
3891
3887
 
3892
- stylesheetVMs.add(vm);
3893
- });
3894
- }
3888
+
3889
+ stylesheetVMs.add(vm);
3890
+ });
3895
3891
  }
3896
3892
  }
3897
3893
  }
@@ -3900,42 +3896,40 @@
3900
3896
  if (process.env.NODE_ENV === 'production') {
3901
3897
  // this method should never leak to prod
3902
3898
  throw new ReferenceError();
3903
- }
3899
+ } // tracking inactive component
3904
3900
 
3905
- if (lwcRuntimeFlags.ENABLE_HMR) {
3906
- // tracking inactive component
3907
- var Ctor = vm.def.ctor;
3908
- var list = activeComponents.get(Ctor);
3909
3901
 
3910
- if (!isUndefined$1(list)) {
3911
- // deleting the vm from the set to avoid leaking memory
3912
- list.delete(vm);
3913
- } // removing inactive template
3902
+ var Ctor = vm.def.ctor;
3903
+ var list = activeComponents.get(Ctor);
3914
3904
 
3905
+ if (!isUndefined$1(list)) {
3906
+ // deleting the vm from the set to avoid leaking memory
3907
+ list.delete(vm);
3908
+ } // removing inactive template
3915
3909
 
3916
- var tpl = vm.cmpTemplate;
3917
3910
 
3918
- if (tpl) {
3919
- list = activeTemplates.get(tpl);
3911
+ var tpl = vm.cmpTemplate;
3920
3912
 
3921
- if (!isUndefined$1(list)) {
3922
- // deleting the vm from the set to avoid leaking memory
3923
- list.delete(vm);
3924
- } // removing active styles associated to template
3913
+ if (tpl) {
3914
+ list = activeTemplates.get(tpl);
3925
3915
 
3916
+ if (!isUndefined$1(list)) {
3917
+ // deleting the vm from the set to avoid leaking memory
3918
+ list.delete(vm);
3919
+ } // removing active styles associated to template
3926
3920
 
3927
- var styles = tpl.stylesheets;
3928
3921
 
3929
- if (!isUndefined$1(styles)) {
3930
- flattenStylesheets(styles).forEach(function (style) {
3931
- list = activeStyles.get(style);
3922
+ var styles = tpl.stylesheets;
3932
3923
 
3933
- if (!isUndefined$1(list)) {
3934
- // deleting the vm from the set to avoid leaking memory
3935
- list.delete(vm);
3936
- }
3937
- });
3938
- }
3924
+ if (!isUndefined$1(styles)) {
3925
+ flattenStylesheets(styles).forEach(function (style) {
3926
+ list = activeStyles.get(style);
3927
+
3928
+ if (!isUndefined$1(list)) {
3929
+ // deleting the vm from the set to avoid leaking memory
3930
+ list.delete(vm);
3931
+ }
3932
+ });
3939
3933
  }
3940
3934
  }
3941
3935
  }
@@ -3950,10 +3944,6 @@
3950
3944
  }
3951
3945
  }
3952
3946
 
3953
- if (!lwcRuntimeFlags.ENABLE_HMR) {
3954
- throw new Error('HMR is not enabled');
3955
- }
3956
-
3957
3947
  return false;
3958
3948
  }
3959
3949
 
@@ -3967,10 +3957,6 @@
3967
3957
  }
3968
3958
  }
3969
3959
 
3970
- if (!lwcRuntimeFlags.ENABLE_HMR) {
3971
- throw new Error('HMR is not enabled');
3972
- }
3973
-
3974
3960
  return false;
3975
3961
  }
3976
3962
 
@@ -3982,10 +3968,6 @@
3982
3968
  return rehydrateHotStyle(oldStyle);
3983
3969
  }
3984
3970
 
3985
- if (!lwcRuntimeFlags.ENABLE_HMR) {
3986
- throw new Error('HMR is not enabled');
3987
- }
3988
-
3989
3971
  return false;
3990
3972
  }
3991
3973
  /*
@@ -4451,14 +4433,17 @@
4451
4433
  /**
4452
4434
  * This function returns the host style token for a custom element if it
4453
4435
  * exists. Otherwise it returns null.
4436
+ *
4437
+ * A host style token is applied to the component if scoped styles are used.
4454
4438
  */
4455
4439
 
4456
4440
 
4457
4441
  function getStylesheetTokenHost(vnode) {
4458
4442
  var _getComponentInternal = getComponentInternalDef(vnode.ctor),
4459
- stylesheetToken = _getComponentInternal.template.stylesheetToken;
4443
+ template = _getComponentInternal.template;
4460
4444
 
4461
- return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
4445
+ var stylesheetToken = template.stylesheetToken;
4446
+ return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
4462
4447
  }
4463
4448
 
4464
4449
  function getNearestNativeShadowComponent(vm) {
@@ -4507,84 +4492,6 @@
4507
4492
 
4508
4493
  return null;
4509
4494
  }
4510
- /*
4511
- * Copyright (c) 2020, salesforce.com, inc.
4512
- * All rights reserved.
4513
- * SPDX-License-Identifier: MIT
4514
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4515
- */
4516
-
4517
-
4518
- function checkHasVM(elm) {
4519
- var hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
4520
-
4521
- if (process.env.NODE_ENV !== 'production' && !hasVM) {
4522
- // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
4523
- // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
4524
- logError("VM for tag name \"".concat(elm.tagName.toLowerCase(), "\" is undefined. ") + "This indicates that an element was created with this tag name, " + "which is already reserved by an LWC component. Use lwc.createElement " + "instead to create elements.");
4525
- }
4526
-
4527
- return hasVM;
4528
- }
4529
-
4530
- function getUpgradableConstructor(tagName, renderer) {
4531
- var getCustomElement = renderer.getCustomElement,
4532
- RendererHTMLElement = renderer.HTMLElementExported,
4533
- defineCustomElement = renderer.defineCustomElement; // Should never get a tag with upper case letter at this point, the compiler should
4534
- // produce only tags with lowercase letters
4535
- // But, for backwards compatibility, we will lower case the tagName
4536
-
4537
- tagName = tagName.toLowerCase();
4538
- var CE = getCustomElement(tagName);
4539
-
4540
- if (!isUndefined$1(CE)) {
4541
- return CE;
4542
- }
4543
- /**
4544
- * LWC Upgradable Element reference to an element that was created
4545
- * via the scoped registry mechanism, and that is ready to be upgraded.
4546
- */
4547
-
4548
-
4549
- CE = /*#__PURE__*/function (_RendererHTMLElement) {
4550
- _inherits(LWCUpgradableElement, _RendererHTMLElement);
4551
-
4552
- var _super5 = _createSuper(LWCUpgradableElement);
4553
-
4554
- function LWCUpgradableElement(upgradeCallback) {
4555
- var _this4;
4556
-
4557
- _classCallCheck(this, LWCUpgradableElement);
4558
-
4559
- _this4 = _super5.call(this);
4560
-
4561
- if (isFunction$1(upgradeCallback)) {
4562
- upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
4563
- }
4564
-
4565
- return _this4;
4566
- }
4567
-
4568
- return _createClass(LWCUpgradableElement);
4569
- }(RendererHTMLElement);
4570
-
4571
- if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4572
- CE.prototype.connectedCallback = function () {
4573
- if (checkHasVM(this)) {
4574
- connectRootElement(this);
4575
- }
4576
- };
4577
-
4578
- CE.prototype.disconnectedCallback = function () {
4579
- if (checkHasVM(this)) {
4580
- disconnectRootElement(this);
4581
- }
4582
- };
4583
- }
4584
-
4585
- defineCustomElement(tagName, CE);
4586
- return CE;
4587
- }
4588
4495
  /*
4589
4496
  * Copyright (c) 2018, salesforce.com, inc.
4590
4497
  * All rights reserved.
@@ -4611,6 +4518,12 @@
4611
4518
  /* VNodeType.CustomElement */
4612
4519
  ;
4613
4520
  }
4521
+
4522
+ function isVScopedSlotFragment(vnode) {
4523
+ return vnode.type === 6
4524
+ /* VNodeType.ScopedSlotFragment */
4525
+ ;
4526
+ }
4614
4527
  /*
4615
4528
  * Copyright (c) 2018, salesforce.com, inc.
4616
4529
  * All rights reserved.
@@ -5144,7 +5057,7 @@
5144
5057
  function mountCustomElement(vnode, parent, anchor, renderer) {
5145
5058
  var sel = vnode.sel,
5146
5059
  owner = vnode.owner;
5147
- var UpgradableConstructor = getUpgradableConstructor(sel, renderer);
5060
+ var createCustomElement = renderer.createCustomElement;
5148
5061
  /**
5149
5062
  * Note: if the upgradable constructor does not expect, or throw when we new it
5150
5063
  * with a callback as the first argument, we could implement a more advanced
@@ -5153,10 +5066,25 @@
5153
5066
  */
5154
5067
 
5155
5068
  var vm;
5156
- var elm = new UpgradableConstructor(function (elm) {
5069
+
5070
+ var upgradeCallback = function upgradeCallback(elm) {
5157
5071
  // the custom element from the registry is expecting an upgrade callback
5158
5072
  vm = createViewModelHook(elm, vnode, renderer);
5159
- });
5073
+ };
5074
+
5075
+ var connectedCallback = function connectedCallback(elm) {
5076
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
5077
+ connectRootElement(elm);
5078
+ }
5079
+ };
5080
+
5081
+ var disconnectedCallback = function disconnectedCallback(elm) {
5082
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
5083
+ disconnectRootElement(elm);
5084
+ }
5085
+ };
5086
+
5087
+ var elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
5160
5088
  vnode.elm = elm;
5161
5089
  vnode.vm = vm;
5162
5090
  linkNodeToShadow(elm, owner, renderer);
@@ -5164,8 +5092,6 @@
5164
5092
 
5165
5093
  if (vm) {
5166
5094
  allocateChildren(vnode, vm);
5167
- } else if (vnode.ctor !== UpgradableConstructor) {
5168
- throw new TypeError("Incorrect Component Constructor");
5169
5095
  }
5170
5096
 
5171
5097
  patchElementPropsAndAttrs$1(null, vnode, renderer);
@@ -5452,7 +5378,7 @@
5452
5378
  /* RenderMode.Light */
5453
5379
  ) {
5454
5380
  // slow path
5455
- allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
5381
+ allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
5456
5382
 
5457
5383
  vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
5458
5384
 
@@ -5486,11 +5412,15 @@
5486
5412
  return vm;
5487
5413
  }
5488
5414
 
5489
- function allocateInSlot(vm, children) {
5490
- var _a;
5415
+ function allocateInSlot(vm, children, owner) {
5416
+ var _a, _b;
5491
5417
 
5492
- var oldSlots = vm.cmpSlots;
5493
- var cmpSlots = vm.cmpSlots = create(null);
5418
+ var oldSlotsMapping = vm.cmpSlots.slotAssignments;
5419
+ var cmpSlotsMapping = create(null);
5420
+ vm.cmpSlots = {
5421
+ owner: owner,
5422
+ slotAssignments: cmpSlotsMapping
5423
+ };
5494
5424
 
5495
5425
  for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
5496
5426
  var vnode = children[_i15];
@@ -5502,19 +5432,21 @@
5502
5432
  var slotName = '';
5503
5433
 
5504
5434
  if (isVBaseElement(vnode)) {
5505
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
5435
+ slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
5436
+ } else if (isVScopedSlotFragment(vnode)) {
5437
+ slotName = vnode.slotName;
5506
5438
  }
5507
5439
 
5508
- var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
5440
+ var vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
5509
5441
  ArrayPush$1.call(vnodes, vnode);
5510
5442
  }
5511
5443
 
5512
5444
  if (isFalse(vm.isDirty)) {
5513
5445
  // We need to determine if the old allocation is really different from the new one
5514
5446
  // and mark the vm as dirty
5515
- var oldKeys = keys(oldSlots);
5447
+ var oldKeys = keys(oldSlotsMapping);
5516
5448
 
5517
- if (oldKeys.length !== keys(cmpSlots).length) {
5449
+ if (oldKeys.length !== keys(cmpSlotsMapping).length) {
5518
5450
  markComponentAsDirty(vm);
5519
5451
  return;
5520
5452
  }
@@ -5522,15 +5454,15 @@
5522
5454
  for (var _i16 = 0, _len4 = oldKeys.length; _i16 < _len4; _i16 += 1) {
5523
5455
  var key = oldKeys[_i16];
5524
5456
 
5525
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5457
+ if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
5526
5458
  markComponentAsDirty(vm);
5527
5459
  return;
5528
5460
  }
5529
5461
 
5530
- var oldVNodes = oldSlots[key];
5531
- var _vnodes = cmpSlots[key];
5462
+ var oldVNodes = oldSlotsMapping[key];
5463
+ var _vnodes = cmpSlotsMapping[key];
5532
5464
 
5533
- for (var j = 0, a = cmpSlots[key].length; j < a; j += 1) {
5465
+ for (var j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
5534
5466
  if (oldVNodes[j] !== _vnodes[j]) {
5535
5467
  markComponentAsDirty(vm);
5536
5468
  return;
@@ -5729,6 +5661,21 @@
5729
5661
 
5730
5662
  function addVNodeToChildLWC(vnode) {
5731
5663
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
5664
+ } // [s]coped [s]lot [f]actory
5665
+
5666
+
5667
+ function ssf(slotName, factory) {
5668
+ return {
5669
+ type: 6
5670
+ /* VNodeType.ScopedSlotFragment */
5671
+ ,
5672
+ factory: factory,
5673
+ owner: getVMBeingRendered(),
5674
+ elm: undefined,
5675
+ sel: undefined,
5676
+ key: undefined,
5677
+ slotName: slotName
5678
+ };
5732
5679
  } // [st]atic node
5733
5680
 
5734
5681
 
@@ -5832,8 +5779,29 @@
5832
5779
  assert.isTrue(isArray$1(children), "h() 3rd argument children must be an array.");
5833
5780
  }
5834
5781
 
5835
- if (!isUndefined$1(slotset) && !isUndefined$1(slotset[slotName]) && slotset[slotName].length !== 0) {
5836
- children = slotset[slotName];
5782
+ if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
5783
+ children = slotset.slotAssignments[slotName].reduce(function (acc, vnode) {
5784
+ // If the passed slot content is factory, evaluate it and use the produced vnodes
5785
+ if (vnode && isVScopedSlotFragment(vnode)) {
5786
+ var vmBeingRenderedInception = getVMBeingRendered();
5787
+ var _children = []; // Evaluate in the scope of the slot content's owner
5788
+ // if a slotset is provided, there will always be an owner. The only case where owner is
5789
+ // undefined is for root components, but root components cannot accept slotted content
5790
+
5791
+ setVMBeingRendered(slotset.owner);
5792
+
5793
+ try {
5794
+ _children = vnode.factory(data.slotData);
5795
+ } finally {
5796
+ setVMBeingRendered(vmBeingRenderedInception);
5797
+ }
5798
+
5799
+ return ArrayConcat$1.call(acc, _children);
5800
+ } else {
5801
+ // If the slot content is a static list of child nodes provided by the parent, nothing to do
5802
+ return ArrayConcat$1.call(acc, vnode);
5803
+ }
5804
+ }, []);
5837
5805
  }
5838
5806
 
5839
5807
  var vmBeingRendered = getVMBeingRendered();
@@ -6240,7 +6208,8 @@
6240
6208
  st: st,
6241
6209
  gid: gid,
6242
6210
  fid: fid,
6243
- shc: shc
6211
+ shc: shc,
6212
+ ssf: ssf
6244
6213
  });
6245
6214
  /*
6246
6215
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6389,9 +6358,9 @@
6389
6358
  var _html$slots = html.slots,
6390
6359
  slots = _html$slots === void 0 ? EmptyArray : _html$slots;
6391
6360
 
6392
- for (var slotName in cmpSlots) {
6361
+ for (var slotName in cmpSlots.slotAssignments) {
6393
6362
  // eslint-disable-next-line @lwc/lwc-internal/no-production-assert
6394
- assert.isTrue(isArray$1(cmpSlots[slotName]), "Slots can only be set to an array, instead received ".concat(toString$1(cmpSlots[slotName]), " for slot \"").concat(slotName, "\" in ").concat(vm, "."));
6363
+ assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), "Slots can only be set to an array, instead received ".concat(toString$1(cmpSlots.slotAssignments[slotName]), " for slot \"").concat(slotName, "\" in ").concat(vm, "."));
6395
6364
 
6396
6365
  if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
6397
6366
  // TODO [#1297]: this should never really happen because the compiler should always validate
@@ -6988,7 +6957,9 @@
6988
6957
  velements: EmptyArray,
6989
6958
  cmpProps: create(null),
6990
6959
  cmpFields: create(null),
6991
- cmpSlots: create(null),
6960
+ cmpSlots: {
6961
+ slotAssignments: create(null)
6962
+ },
6992
6963
  oar: create(null),
6993
6964
  cmpTemplate: null,
6994
6965
  hydrated: Boolean(hydrated),
@@ -7509,21 +7480,21 @@
7509
7480
  var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
7510
7481
  _inherits(WireContextRegistrationEvent, _CustomEvent);
7511
7482
 
7512
- var _super6 = _createSuper(WireContextRegistrationEvent);
7483
+ var _super5 = _createSuper(WireContextRegistrationEvent);
7513
7484
 
7514
7485
  function WireContextRegistrationEvent(adapterToken, _ref3) {
7515
- var _this5;
7486
+ var _this4;
7516
7487
 
7517
7488
  var setNewContext = _ref3.setNewContext,
7518
7489
  setDisconnectedCallback = _ref3.setDisconnectedCallback;
7519
7490
 
7520
7491
  _classCallCheck(this, WireContextRegistrationEvent);
7521
7492
 
7522
- _this5 = _super6.call(this, adapterToken, {
7493
+ _this4 = _super5.call(this, adapterToken, {
7523
7494
  bubbles: true,
7524
7495
  composed: true
7525
7496
  });
7526
- defineProperties(_assertThisInitialized(_this5), {
7497
+ defineProperties(_assertThisInitialized(_this4), {
7527
7498
  setNewContext: {
7528
7499
  value: setNewContext
7529
7500
  },
@@ -7531,7 +7502,7 @@
7531
7502
  value: setDisconnectedCallback
7532
7503
  }
7533
7504
  });
7534
- return _this5;
7505
+ return _this4;
7535
7506
  }
7536
7507
 
7537
7508
  return _createClass(WireContextRegistrationEvent);
@@ -8232,13 +8203,27 @@
8232
8203
  // Consequently, hydration mismatches will occur if scoped CSS token classnames
8233
8204
  // are rendered during SSR. This needs to be accounted for when validating.
8234
8205
 
8235
- if (scopedToken) {
8206
+ if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
8236
8207
  if (!isUndefined$1(className)) {
8237
- className = isNull(stylesheetTokenHost) ? "".concat(scopedToken, " ").concat(className) : "".concat(scopedToken, " ").concat(className, " ").concat(stylesheetTokenHost);
8208
+ // The order of the className should be scopedToken className stylesheetTokenHost
8209
+ var classTokens = [scopedToken, className, stylesheetTokenHost];
8210
+ var classNames = ArrayFilter.call(classTokens, function (token) {
8211
+ return !isNull(token);
8212
+ });
8213
+ className = ArrayJoin.call(classNames, ' ');
8238
8214
  } else if (!isUndefined$1(classMap)) {
8239
- classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ? {} : _defineProperty({}, stylesheetTokenHost, true));
8215
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), !isNull(scopedToken) ? _defineProperty({}, scopedToken, true) : {}), !isNull(stylesheetTokenHost) ? _defineProperty({}, stylesheetTokenHost, true) : {});
8240
8216
  } else {
8241
- className = isNull(stylesheetTokenHost) ? "".concat(scopedToken) : "".concat(scopedToken, " ").concat(stylesheetTokenHost);
8217
+ // The order of the className should be scopedToken stylesheetTokenHost
8218
+ var _classTokens = [scopedToken, stylesheetTokenHost];
8219
+
8220
+ var _classNames = ArrayFilter.call(_classTokens, function (token) {
8221
+ return !isNull(token);
8222
+ });
8223
+
8224
+ if (_classNames.length) {
8225
+ className = ArrayJoin.call(_classNames, ' ');
8226
+ }
8242
8227
  }
8243
8228
  }
8244
8229
 
@@ -8554,7 +8539,7 @@
8554
8539
 
8555
8540
  return ctor;
8556
8541
  }
8557
- /* version: 2.25.1 */
8542
+ /* version: 2.27.0 */
8558
8543
 
8559
8544
  /*
8560
8545
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8714,6 +8699,779 @@
8714
8699
  insertLocalStylesheet(content, target);
8715
8700
  }
8716
8701
  }
8702
+ /*
8703
+ * Copyright (c) 2020, salesforce.com, inc.
8704
+ * All rights reserved.
8705
+ * SPDX-License-Identifier: MIT
8706
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8707
+ */
8708
+
8709
+
8710
+ function isCustomElementRegistryAvailable() {
8711
+ if (typeof customElements === 'undefined') {
8712
+ return false;
8713
+ }
8714
+
8715
+ try {
8716
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
8717
+ // _wrapNativeSuper()
8718
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
8719
+ // get wrapped by babel.
8720
+ var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
8721
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
8722
+ // which are not equipped to be initialized that way.
8723
+
8724
+ var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
8725
+ _inherits(clazz, _HTMLElementAlias);
8726
+
8727
+ var _super6 = _createSuper(clazz);
8728
+
8729
+ function clazz() {
8730
+ _classCallCheck(this, clazz);
8731
+
8732
+ return _super6.apply(this, arguments);
8733
+ }
8734
+
8735
+ return _createClass(clazz);
8736
+ }(HTMLElementAlias);
8737
+
8738
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
8739
+ new clazz();
8740
+ return true;
8741
+ } catch (_a) {
8742
+ return false;
8743
+ }
8744
+ }
8745
+
8746
+ var hasCustomElements = isCustomElementRegistryAvailable();
8747
+ /*
8748
+ * Copyright (c) 2018, salesforce.com, inc.
8749
+ * All rights reserved.
8750
+ * SPDX-License-Identifier: MIT
8751
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8752
+ */
8753
+ // Creates a custom element for compat (legacy) browser environments
8754
+
8755
+ var createCustomElementCompat = function createCustomElementCompat(tagName, upgradeCallback) {
8756
+ var elm = document.createElement(tagName);
8757
+ upgradeCallback(elm); // nothing to do with the result for now
8758
+
8759
+ return elm;
8760
+ };
8761
+ /*
8762
+ * Copyright (c) 2018, salesforce.com, inc.
8763
+ * All rights reserved.
8764
+ * SPDX-License-Identifier: MIT
8765
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8766
+ */
8767
+
8768
+
8769
+ var cachedConstructors = new Map();
8770
+ var elementsUpgradedOutsideLWC = new WeakSet();
8771
+ var elementBeingUpgradedByLWC = false; // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
8772
+ // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
8773
+ // Another benefit is that only LWC can create components that actually do anything – if you do
8774
+ // `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
8775
+ // This class should be created once per tag name.
8776
+
8777
+ var createUpgradableConstructor = function createUpgradableConstructor(_connectedCallback, _disconnectedCallback) {
8778
+ // TODO [#2972]: this class should expose observedAttributes as necessary
8779
+ return /*#__PURE__*/function (_HTMLElement) {
8780
+ _inherits(UpgradableConstructor, _HTMLElement);
8781
+
8782
+ var _super7 = _createSuper(UpgradableConstructor);
8783
+
8784
+ function UpgradableConstructor(upgradeCallback) {
8785
+ var _this5;
8786
+
8787
+ _classCallCheck(this, UpgradableConstructor);
8788
+
8789
+ _this5 = _super7.call(this); // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
8790
+ // then elementBeingUpgraded will be false
8791
+
8792
+ if (elementBeingUpgradedByLWC) {
8793
+ upgradeCallback(_assertThisInitialized(_this5));
8794
+ } else {
8795
+ // keep track of elements that were not created by lwc.createElement,
8796
+ // so we can ignore their lifecycle hooks
8797
+ elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this5)); // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
8798
+ // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8799
+ }
8800
+
8801
+ return _this5;
8802
+ }
8803
+
8804
+ _createClass(UpgradableConstructor, [{
8805
+ key: "connectedCallback",
8806
+ value: function connectedCallback() {
8807
+ if (!elementsUpgradedOutsideLWC.has(this)) {
8808
+ _connectedCallback(this);
8809
+ }
8810
+ }
8811
+ }, {
8812
+ key: "disconnectedCallback",
8813
+ value: function disconnectedCallback() {
8814
+ if (!elementsUpgradedOutsideLWC.has(this)) {
8815
+ _disconnectedCallback(this);
8816
+ }
8817
+ }
8818
+ }]);
8819
+
8820
+ return UpgradableConstructor;
8821
+ }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
8822
+ };
8823
+
8824
+ var createCustomElementVanilla = function createCustomElementVanilla(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
8825
+ // use global custom elements registry
8826
+ var UpgradableConstructor = cachedConstructors.get(tagName);
8827
+
8828
+ if (isUndefined$1(UpgradableConstructor)) {
8829
+ if (!isUndefined$1(customElements.get(tagName))) {
8830
+ throw new Error("Unexpected tag name \"".concat(tagName, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
8831
+ }
8832
+
8833
+ UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
8834
+ customElements.define(tagName, UpgradableConstructor);
8835
+ cachedConstructors.set(tagName, UpgradableConstructor);
8836
+ }
8837
+
8838
+ elementBeingUpgradedByLWC = true;
8839
+
8840
+ try {
8841
+ return new UpgradableConstructor(upgradeCallback);
8842
+ } finally {
8843
+ elementBeingUpgradedByLWC = false;
8844
+ }
8845
+ };
8846
+ /*
8847
+ * Copyright (c) 2020, salesforce.com, inc.
8848
+ * All rights reserved.
8849
+ * SPDX-License-Identifier: MIT
8850
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8851
+ */
8852
+
8853
+ /**
8854
+ * Create a scoped registry, i.e. a function that can create custom elements whose tag names
8855
+ * do not conflict with vanilla custom elements having the same tag name.
8856
+ */
8857
+
8858
+
8859
+ function createScopedRegistry() {
8860
+ if (!hasCustomElements) {
8861
+ // This code should never be reached, because we don't use the pivot registry if
8862
+ // custom elements are unavailable.
8863
+ throw new Error('Custom elements are not supported in this environment.');
8864
+ }
8865
+
8866
+ var _window = window,
8867
+ NativeHTMLElement = _window.HTMLElement;
8868
+ var _NativeHTMLElement$pr = NativeHTMLElement.prototype,
8869
+ nativeHasAttribute = _NativeHTMLElement$pr.hasAttribute,
8870
+ nativeSetAttribute = _NativeHTMLElement$pr.setAttribute,
8871
+ nativeRemoveAttribute = _NativeHTMLElement$pr.removeAttribute,
8872
+ nativeGetAttribute = _NativeHTMLElement$pr.getAttribute;
8873
+ var definitionForElement = new WeakMap();
8874
+ var pendingRegistryForElement = new WeakMap();
8875
+ var definitionForConstructor = new WeakMap();
8876
+ var registeredUserCtors = new WeakSet();
8877
+ var pivotCtorByTag = new Map();
8878
+ var globalDefinitionsByTag = new Map();
8879
+ var globalDefinitionsByClass = new Map();
8880
+ var awaitingUpgrade = new Map();
8881
+ var EMPTY_SET = new Set();
8882
+
8883
+ function createDefinitionRecord(constructor) {
8884
+ var _a;
8885
+
8886
+ var _constructor$prototyp = constructor.prototype,
8887
+ connectedCallback = _constructor$prototyp.connectedCallback,
8888
+ disconnectedCallback = _constructor$prototyp.disconnectedCallback,
8889
+ adoptedCallback = _constructor$prototyp.adoptedCallback,
8890
+ attributeChangedCallback = _constructor$prototyp.attributeChangedCallback;
8891
+ var observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
8892
+ return {
8893
+ UserCtor: constructor,
8894
+ PivotCtor: undefined,
8895
+ connectedCallback: connectedCallback,
8896
+ disconnectedCallback: disconnectedCallback,
8897
+ adoptedCallback: adoptedCallback,
8898
+ attributeChangedCallback: attributeChangedCallback,
8899
+ observedAttributes: observedAttributes
8900
+ };
8901
+ } // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
8902
+ // element. Note that the `registeredDefinition` represents the constructor that was used to register during
8903
+ // `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
8904
+ // constructor is invoked with another constructor.
8905
+
8906
+
8907
+ function createPivotingClass(tagName, registeredDefinition) {
8908
+ var PivotCtor = /*#__PURE__*/function (_NativeHTMLElement) {
8909
+ _inherits(PivotCtor, _NativeHTMLElement);
8910
+
8911
+ var _super8 = _createSuper(PivotCtor);
8912
+
8913
+ function PivotCtor(UserCtor) {
8914
+ var _this6;
8915
+
8916
+ _classCallCheck(this, PivotCtor);
8917
+
8918
+ // This constructor can only be invoked by:
8919
+ // a) the browser instantiating an element from parsing or via document.createElement.
8920
+ // b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
8921
+ // b) new UserClass.
8922
+ // When LWC instantiates it, it will pass the upgrading definition as an argument
8923
+ // If the caller signals via UserCtor that this is in fact a controlled
8924
+ // definition, we use that one, otherwise fallback to the global
8925
+ // internal registry.
8926
+ _this6 = _super8.call(this);
8927
+ var userCtorIsDefined = !isUndefined$1(UserCtor);
8928
+
8929
+ if (userCtorIsDefined) {
8930
+ if (!isConstructor(UserCtor)) {
8931
+ throw new TypeError("Failed to create custom element: the provided constructor is not a constructor.");
8932
+ }
8933
+
8934
+ if (!registeredUserCtors.has(UserCtor)) {
8935
+ throw new Error("Failed to create custom element: the provided constructor is unregistered: ".concat(UserCtor.name, "."));
8936
+ }
8937
+ }
8938
+
8939
+ var definition = userCtorIsDefined ? getOrCreateDefinitionForConstructor(UserCtor) : globalDefinitionsByTag.get(tagName);
8940
+
8941
+ if (!isUndefined$1(definition)) {
8942
+ internalUpgrade(_assertThisInitialized(_this6), registeredDefinition, definition);
8943
+ } else {
8944
+ // This is the case in which there is no global definition, and
8945
+ // it is not handled by LWC (otherwise it will have a valid UserCtor)
8946
+ // so we need to add it to the pending queue just in case it eventually
8947
+ // gets defined in the global registry.
8948
+ pendingRegistryForElement.set(_assertThisInitialized(_this6), registeredDefinition);
8949
+ }
8950
+
8951
+ return _this6;
8952
+ }
8953
+
8954
+ _createClass(PivotCtor, [{
8955
+ key: "connectedCallback",
8956
+ value: function connectedCallback() {
8957
+ var _a;
8958
+
8959
+ var definition = definitionForElement.get(this);
8960
+
8961
+ if (!isUndefined$1(definition)) {
8962
+ // Delegate out to user callback
8963
+ (_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
8964
+ } else {
8965
+ // Register for upgrade when defined (only when connected, so we don't leak)
8966
+ var awaiting = awaitingUpgrade.get(tagName);
8967
+
8968
+ if (isUndefined$1(awaiting)) {
8969
+ awaitingUpgrade.set(tagName, awaiting = new Set());
8970
+ }
8971
+
8972
+ awaiting.add(this);
8973
+ }
8974
+ }
8975
+ }, {
8976
+ key: "disconnectedCallback",
8977
+ value: function disconnectedCallback() {
8978
+ var _a;
8979
+
8980
+ var definition = definitionForElement.get(this);
8981
+
8982
+ if (!isUndefined$1(definition)) {
8983
+ // Delegate out to user callback
8984
+ (_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
8985
+ } else {
8986
+ // Un-register for upgrade when defined (so we don't leak)
8987
+ var awaiting = awaitingUpgrade.get(tagName); // At this point, awaiting should never be undefined, because connectedCallback
8988
+ // must have been called before disconnectedCallback. But just to be safe, we check
8989
+
8990
+ if (!isUndefined$1(awaiting)) {
8991
+ awaiting.delete(this);
8992
+ }
8993
+ }
8994
+ }
8995
+ }, {
8996
+ key: "adoptedCallback",
8997
+ value: function adoptedCallback() {
8998
+ var _a;
8999
+
9000
+ var definition = definitionForElement.get(this);
9001
+ (_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
9002
+ }
9003
+ }, {
9004
+ key: "attributeChangedCallback",
9005
+ value: function attributeChangedCallback(name, oldValue, newValue) {
9006
+ var _a;
9007
+
9008
+ var definition = definitionForElement.get(this); // if both definitions are the same, then the observedAttributes is the same,
9009
+ // but if they are different, only if the runtime definition has the attribute
9010
+ // marked as observed, then it should invoke attributeChangedCallback.
9011
+
9012
+ if (registeredDefinition === definition || (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
9013
+ (_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
9014
+ }
9015
+ }
9016
+ }]);
9017
+
9018
+ return PivotCtor;
9019
+ }(NativeHTMLElement);
9020
+
9021
+ PivotCtor.observedAttributes = _toConsumableArray(registeredDefinition.observedAttributes);
9022
+ return PivotCtor;
9023
+ }
9024
+
9025
+ function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
9026
+ var observedAttributes = pivotDefinition.observedAttributes,
9027
+ attributeChangedCallback = pivotDefinition.attributeChangedCallback;
9028
+
9029
+ if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
9030
+ // This instance does not need to observe any attributes, no need to patch
9031
+ return EMPTY_SET;
9032
+ } // Natively, the attributes observed by the registered definition are going to be taken
9033
+ // care of by the browser, only the difference between the two sets has to be taken
9034
+ // care by the patched version.
9035
+
9036
+
9037
+ return new Set(_toConsumableArray(pivotDefinition.observedAttributes).filter(function (x) {
9038
+ return !registeredDefinition.observedAttributes.has(x);
9039
+ }));
9040
+ }
9041
+
9042
+ function throwAsyncError(error) {
9043
+ // Per native custom element behavior, errors thrown in attributeChangedCallback
9044
+ // become unhandled async errors. We use setTimeout() instead of Promise.resolve()
9045
+ // to make it an unhandled error rather than an unhandled rejection.
9046
+ setTimeout(function () {
9047
+ throw error;
9048
+ });
9049
+ } // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
9050
+ // Why is this necessary? Well basically, you can't change the `observedAttributes` after
9051
+ // a custom element is defined. So with pivots, if two classes share the same tag name,
9052
+ // and the second class observes attributes that aren't observed by the first one,
9053
+ // then those attributes can never be observed by the native `observedAttributes` system.
9054
+ // So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
9055
+ // we only do this when absolutely necessary, though; i.e. because we've determined
9056
+ // that we aren't observing the attributes we need to.
9057
+
9058
+
9059
+ function patchAttributes(instance, registeredDefinition, pivotDefinition) {
9060
+ var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
9061
+
9062
+ if (newObservedAttributes.size === 0) {
9063
+ return;
9064
+ }
9065
+
9066
+ var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Patch the instance.
9067
+ // Note we use the native `getAttribute` rather than the super's `getAttribute` because
9068
+ // we don't actually want it to be observable that we're calling `getAttribute` from
9069
+ // `setAttribute` and `removeAttribute`.
9070
+ // TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
9071
+
9072
+ defineProperties(instance, {
9073
+ setAttribute: {
9074
+ value: function setAttribute(name, value) {
9075
+ if (newObservedAttributes.has(name)) {
9076
+ var old = nativeGetAttribute.call(this, name);
9077
+ nativeSetAttribute.call(this, name, value);
9078
+
9079
+ try {
9080
+ attributeChangedCallback.call(this, name, old, value + '');
9081
+ } catch (error) {
9082
+ throwAsyncError(error);
9083
+ }
9084
+ } else {
9085
+ nativeSetAttribute.call(this, name, value);
9086
+ }
9087
+ },
9088
+ writable: true,
9089
+ enumerable: true,
9090
+ configurable: true
9091
+ },
9092
+ removeAttribute: {
9093
+ value: function removeAttribute(name) {
9094
+ if (newObservedAttributes.has(name)) {
9095
+ var old = nativeGetAttribute.call(this, name);
9096
+ nativeRemoveAttribute.call(this, name);
9097
+
9098
+ try {
9099
+ attributeChangedCallback.call(this, name, old, null);
9100
+ } catch (error) {
9101
+ throwAsyncError(error);
9102
+ }
9103
+ } else {
9104
+ nativeRemoveAttribute.call(this, name);
9105
+ }
9106
+ },
9107
+ writable: true,
9108
+ enumerable: true,
9109
+ configurable: true
9110
+ }
9111
+ });
9112
+ }
9113
+
9114
+ function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
9115
+ // The below case patches observed attributes for the case where the HTML element is upgraded
9116
+ // from a pre-existing one in the DOM.
9117
+ var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
9118
+
9119
+ if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
9120
+ return;
9121
+ }
9122
+
9123
+ var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Approximate observedAttributes from the user class, but only for the new observed attributes
9124
+
9125
+ newObservedAttributes.forEach(function (name) {
9126
+ if (nativeHasAttribute.call(instance, name)) {
9127
+ var newValue = nativeGetAttribute.call(instance, name);
9128
+ attributeChangedCallback.call(instance, name, null, newValue);
9129
+ }
9130
+ });
9131
+ } // User extends this HTMLElement, which returns the CE being upgraded
9132
+
9133
+
9134
+ var upgradingInstance; // Helper to upgrade an instance with a CE definition using "constructor call trick"
9135
+
9136
+ function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
9137
+ setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
9138
+ definitionForElement.set(instance, pivotDefinition); // attributes patches when needed
9139
+
9140
+ if (pivotDefinition !== registeredDefinition) {
9141
+ patchAttributes(instance, registeredDefinition, pivotDefinition);
9142
+ } // Tricking the construction path to believe that a new instance is being created,
9143
+ // that way it will execute the super initialization mechanism but the HTMLElement
9144
+ // constructor will reuse the instance by returning the upgradingInstance.
9145
+ // This is by far the most important piece of the puzzle
9146
+
9147
+
9148
+ upgradingInstance = instance; // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
9149
+ // The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
9150
+ // Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
9151
+
9152
+ new pivotDefinition.UserCtor();
9153
+ patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
9154
+ }
9155
+
9156
+ function isConstructor(constructor) {
9157
+ return isFunction$1(constructor) && isObject(constructor.prototype);
9158
+ }
9159
+
9160
+ function getOrCreateDefinitionForConstructor(constructor) {
9161
+ if (!isConstructor(constructor)) {
9162
+ throw new TypeError('The referenced constructor is not a constructor.');
9163
+ }
9164
+
9165
+ var definition = definitionForConstructor.get(constructor);
9166
+
9167
+ if (!isUndefined$1(definition)) {
9168
+ return definition;
9169
+ }
9170
+
9171
+ return createDefinitionRecord(constructor);
9172
+ }
9173
+
9174
+ var _window2 = window,
9175
+ nativeRegistry = _window2.customElements;
9176
+ var nativeDefine = nativeRegistry.define,
9177
+ nativeWhenDefined = nativeRegistry.whenDefined,
9178
+ nativeGet = nativeRegistry.get; // patch for the global registry define mechanism
9179
+
9180
+ CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
9181
+ if (options && options.extends) {
9182
+ // TODO [#2983]: should we support `extends`?
9183
+ throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
9184
+ }
9185
+
9186
+ if (globalDefinitionsByTag.has(tagName)) {
9187
+ throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"".concat(tagName, "\" has already been used with this registry"));
9188
+ }
9189
+
9190
+ if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
9191
+ throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");
9192
+ }
9193
+
9194
+ var definition = getOrCreateDefinitionForConstructor(constructor);
9195
+ registeredUserCtors.add(constructor);
9196
+ var PivotCtor = pivotCtorByTag.get(tagName);
9197
+
9198
+ if (isUndefined$1(PivotCtor)) {
9199
+ PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class which will handle global registry initializations
9200
+
9201
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
9202
+ } // Only cache after nativeDefine has been called, because if it throws an error
9203
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
9204
+
9205
+
9206
+ definitionForConstructor.set(constructor, definition);
9207
+ pivotCtorByTag.set(tagName, PivotCtor);
9208
+ globalDefinitionsByTag.set(tagName, definition);
9209
+ globalDefinitionsByClass.set(constructor, definition); // For globally defined custom elements, the definition associated
9210
+ // to the UserCtor has a back-pointer to PivotCtor in case the user
9211
+ // new the UserCtor, so we know how to create the underlying element.
9212
+
9213
+ definition.PivotCtor = PivotCtor; // Upgrade any elements created in this scope before customElements.define
9214
+ // was called, which should be exhibited by the following steps:
9215
+ // 1) LWC registers a tagName for an LWC component.
9216
+ // 2) Element with same tagName is created with document.createElement()
9217
+ // and inserted into DOM.
9218
+ // 3) customElements.define() is called with tagName and non-LWC constructor.
9219
+ // This requires immediate upgrade when the new global tagName is defined.
9220
+
9221
+ var awaiting = awaitingUpgrade.get(tagName);
9222
+
9223
+ if (!isUndefined$1(awaiting)) {
9224
+ awaitingUpgrade.delete(tagName);
9225
+
9226
+ var _iterator6 = _createForOfIteratorHelper(awaiting),
9227
+ _step6;
9228
+
9229
+ try {
9230
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
9231
+ var element = _step6.value;
9232
+ var registeredDefinition = pendingRegistryForElement.get(element); // At this point, registeredDefinition should never be undefined because awaitingUpgrade
9233
+ // is only populated when we haven't run internalUpgrade yet, and we only populate
9234
+ // pendingRegistryForElement when internalUpgrade hasn't run yet.
9235
+ // But just to be safe, we check.
9236
+
9237
+ if (!isUndefined$1(registeredDefinition)) {
9238
+ pendingRegistryForElement.delete(element);
9239
+ internalUpgrade(element, registeredDefinition, definition);
9240
+ }
9241
+ }
9242
+ } catch (err) {
9243
+ _iterator6.e(err);
9244
+ } finally {
9245
+ _iterator6.f();
9246
+ }
9247
+ }
9248
+ };
9249
+
9250
+ CustomElementRegistry.prototype.get = function get(tagName) {
9251
+ var NativeCtor = nativeGet.call(nativeRegistry, tagName);
9252
+
9253
+ if (!isUndefined$1(NativeCtor)) {
9254
+ var definition = globalDefinitionsByTag.get(tagName);
9255
+
9256
+ if (!isUndefined$1(definition)) {
9257
+ return definition.UserCtor; // defined by the patched custom elements registry
9258
+ } // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
9259
+
9260
+
9261
+ return NativeCtor; // return the pivot constructor or constructor that existed before patching
9262
+ }
9263
+ };
9264
+
9265
+ CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
9266
+ return nativeWhenDefined.call(nativeRegistry, tagName).then(function (NativeCtor) {
9267
+ var definition = globalDefinitionsByTag.get(tagName);
9268
+
9269
+ if (!isUndefined$1(definition)) {
9270
+ return definition.UserCtor;
9271
+ } // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
9272
+ // In this case, the custom element must have been defined before the registry patches
9273
+ // were applied. So return the non-pivot constructor
9274
+
9275
+
9276
+ if (isUndefined$1(NativeCtor)) {
9277
+ // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
9278
+ // We can patch the correct behavior using customElements.get()
9279
+ return nativeGet.call(nativeRegistry, tagName);
9280
+ }
9281
+
9282
+ return NativeCtor;
9283
+ });
9284
+ }; // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
9285
+ // @ts-ignore
9286
+
9287
+
9288
+ window.HTMLElement = function HTMLElement() {
9289
+ // Upgrading case: the pivoting class constructor was run by the browser's
9290
+ // native custom elements and we're in the process of running the
9291
+ // "constructor-call trick" on the natively constructed instance, so just
9292
+ // return that here.
9293
+ // This code path is also called when LWC `new`s a PivotCtor.
9294
+ var instance = upgradingInstance;
9295
+
9296
+ if (!isUndefined$1(instance)) {
9297
+ upgradingInstance = undefined;
9298
+ return instance;
9299
+ } // Construction case: we need to construct the pivoting instance and return it.
9300
+ // This is possible when the user register it via global registry and instantiate
9301
+ // it via `new Ctor()`.
9302
+
9303
+
9304
+ var constructor = this.constructor;
9305
+ var definition = globalDefinitionsByClass.get(constructor);
9306
+
9307
+ if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
9308
+ // This code path is hit if someone `new`s a class that extends `HTMLElement` without
9309
+ // doing `customElements.define()` first. This matches native browser behavior:
9310
+ // https://stackoverflow.com/a/61883392
9311
+ throw new TypeError('Illegal constructor');
9312
+ } // This constructor is ONLY invoked when it is the user instantiating
9313
+ // an element via new Ctor while Ctor is a registered global constructor.
9314
+
9315
+
9316
+ var PivotCtor = definition.PivotCtor,
9317
+ UserCtor = definition.UserCtor;
9318
+ return new PivotCtor(UserCtor);
9319
+ };
9320
+
9321
+ HTMLElement.prototype = NativeHTMLElement.prototype;
9322
+ /**
9323
+ * Create a new PivotConstructor for the given tagName, which is capable of being constructed
9324
+ * with a UserConstructor defining the behavior. Passing in the UserConstructor here
9325
+ * is a hint that can be used when registering a custom element with the global custom elements
9326
+ * registry for the first time, which provides certain optimizations. It also marks the UserConstructor
9327
+ * as "safe" to be used when passed in to a PivotConstructor.
9328
+ *
9329
+ * @param tagName - element tag name
9330
+ * @param UserCtor - userland custom element constructor
9331
+ * @returns a new custom element constructor
9332
+ */
9333
+
9334
+ return function createPivotConstructor(tagName, UserCtor) {
9335
+ tagName = StringToLowerCase.call(tagName);
9336
+ var PivotCtor = pivotCtorByTag.get(tagName);
9337
+
9338
+ if (isUndefined$1(PivotCtor)) {
9339
+ var definition = getOrCreateDefinitionForConstructor(UserCtor);
9340
+ PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class as a global custom element
9341
+
9342
+ nativeDefine.call(nativeRegistry, tagName, PivotCtor);
9343
+ definition.PivotCtor = PivotCtor; // Only cache after nativeDefine has been called, because if it throws an error
9344
+ // (e.g. for an invalid tag name), then we don't want to cache anything.
9345
+
9346
+ definitionForConstructor.set(UserCtor, definition);
9347
+ pivotCtorByTag.set(tagName, PivotCtor);
9348
+ } // Register a UserConstructor as "safe" to be used within a PivotConstructor
9349
+
9350
+
9351
+ registeredUserCtors.add(UserCtor);
9352
+ return PivotCtor;
9353
+ };
9354
+ }
9355
+ /*
9356
+ * Copyright (c) 2018, salesforce.com, inc.
9357
+ * All rights reserved.
9358
+ * SPDX-License-Identifier: MIT
9359
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9360
+ */
9361
+
9362
+
9363
+ var createScopedConstructor;
9364
+ var CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
9365
+ // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
9366
+ // or we're in a legacy browser.
9367
+
9368
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
9369
+ if (hasCustomElements) {
9370
+ // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
9371
+ // It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
9372
+ //
9373
+ // Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
9374
+ //
9375
+ // 1. LWC loads
9376
+ // 2. `const Ctor = class extends HTMLElement {}`
9377
+ // 3. `lwc.createElement(...)` // here we lazily patch
9378
+ // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
9379
+ //
9380
+ // To reduce the risk of this, it's safer to patch the registry eagerly.
9381
+ createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
9382
+ // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
9383
+ // because the HTMLElement prototypes are mixed up.
9384
+ //
9385
+ // The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
9386
+ // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
9387
+ // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
9388
+ // Caching avoids this problem.
9389
+
9390
+ CachedHTMLElement = window.HTMLElement;
9391
+ }
9392
+ } // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
9393
+ // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
9394
+ // multiple times per tag name.
9395
+
9396
+
9397
+ var createUserConstructor = function createUserConstructor(upgradeCallback, _connectedCallback2, _disconnectedCallback2, HTMLElementToExtend) {
9398
+ // TODO [#2972]: this class should expose observedAttributes as necessary
9399
+ return /*#__PURE__*/function (_HTMLElementToExtend) {
9400
+ _inherits(UserConstructor, _HTMLElementToExtend);
9401
+
9402
+ var _super9 = _createSuper(UserConstructor);
9403
+
9404
+ function UserConstructor() {
9405
+ var _this7;
9406
+
9407
+ _classCallCheck(this, UserConstructor);
9408
+
9409
+ _this7 = _super9.call(this);
9410
+ upgradeCallback(_assertThisInitialized(_this7));
9411
+ return _this7;
9412
+ }
9413
+
9414
+ _createClass(UserConstructor, [{
9415
+ key: "connectedCallback",
9416
+ value: function connectedCallback() {
9417
+ _connectedCallback2(this);
9418
+ }
9419
+ }, {
9420
+ key: "disconnectedCallback",
9421
+ value: function disconnectedCallback() {
9422
+ _disconnectedCallback2(this);
9423
+ }
9424
+ }]);
9425
+
9426
+ return UserConstructor;
9427
+ }(HTMLElementToExtend);
9428
+ };
9429
+
9430
+ function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
9431
+ if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
9432
+ // This error should be impossible to hit
9433
+ throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
9434
+ }
9435
+
9436
+ var UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
9437
+ var ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
9438
+ return new ScopedConstructor(UserConstructor);
9439
+ }
9440
+ /*
9441
+ * Copyright (c) 2018, salesforce.com, inc.
9442
+ * All rights reserved.
9443
+ * SPDX-License-Identifier: MIT
9444
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9445
+ */
9446
+
9447
+ /**
9448
+ * We have three modes for creating custom elements:
9449
+ *
9450
+ * 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
9451
+ * 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
9452
+ * same tag name, via a simple trick: every custom element constructor we define in the registry is basically
9453
+ * the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
9454
+ * constructor, which allows us to have completely customized functionality for different components.
9455
+ * 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
9456
+ * elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
9457
+ * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
9458
+ * because it must patch the global `customElements` and `HTMLElement` objects.
9459
+ */
9460
+
9461
+
9462
+ var createCustomElement;
9463
+
9464
+ if (hasCustomElements) {
9465
+ if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
9466
+ createCustomElement = createCustomElementScoped;
9467
+ } else {
9468
+ // use global custom elements registry (vanilla)
9469
+ createCustomElement = createCustomElementVanilla;
9470
+ }
9471
+ } else {
9472
+ // no registry available here
9473
+ createCustomElement = createCustomElementCompat;
9474
+ }
8717
9475
  /*
8718
9476
  * Copyright (c) 2018, salesforce.com, inc.
8719
9477
  * All rights reserved.
@@ -8782,7 +9540,7 @@
8782
9540
  function isNull(obj) {
8783
9541
  return obj === null;
8784
9542
  }
8785
- /** version: 2.25.1 */
9543
+ /** version: 2.27.0 */
8786
9544
 
8787
9545
  /*
8788
9546
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8792,87 +9550,6 @@
8792
9550
  */
8793
9551
 
8794
9552
 
8795
- exports.getCustomElement = void 0;
8796
- exports.defineCustomElement = void 0;
8797
- var HTMLElementConstructor;
8798
-
8799
- function isCustomElementRegistryAvailable() {
8800
- if (typeof customElements === 'undefined') {
8801
- return false;
8802
- }
8803
-
8804
- try {
8805
- // dereference HTMLElement global because babel wraps globals in compat mode with a
8806
- // _wrapNativeSuper()
8807
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
8808
- // get wrapped by babel.
8809
- var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
8810
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
8811
- // which are not equipped to be initialized that way.
8812
-
8813
- var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
8814
- _inherits(clazz, _HTMLElementAlias);
8815
-
8816
- var _super7 = _createSuper(clazz);
8817
-
8818
- function clazz() {
8819
- _classCallCheck(this, clazz);
8820
-
8821
- return _super7.apply(this, arguments);
8822
- }
8823
-
8824
- return _createClass(clazz);
8825
- }(HTMLElementAlias);
8826
-
8827
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
8828
- new clazz();
8829
- return true;
8830
- } catch (_a) {
8831
- return false;
8832
- }
8833
- }
8834
-
8835
- if (isCustomElementRegistryAvailable()) {
8836
- exports.getCustomElement = customElements.get.bind(customElements);
8837
- exports.defineCustomElement = customElements.define.bind(customElements);
8838
- HTMLElementConstructor = HTMLElement;
8839
- } else {
8840
- var registry = Object.create(null);
8841
- var reverseRegistry = new WeakMap();
8842
-
8843
- exports.defineCustomElement = function define(name, ctor) {
8844
- if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
8845
- throw new TypeError("Invalid Registration");
8846
- }
8847
-
8848
- registry[name] = ctor;
8849
- reverseRegistry.set(ctor, name);
8850
- };
8851
-
8852
- exports.getCustomElement = function get(name) {
8853
- return registry[name];
8854
- };
8855
-
8856
- HTMLElementConstructor = function HTMLElement() {
8857
- if (!(this instanceof HTMLElement)) {
8858
- throw new TypeError("Invalid Invocation");
8859
- }
8860
-
8861
- var constructor = this.constructor;
8862
- var name = reverseRegistry.get(constructor);
8863
-
8864
- if (!name) {
8865
- throw new TypeError("Invalid Construction");
8866
- }
8867
-
8868
- var elm = document.createElement(name);
8869
- Object.setPrototypeOf(elm, constructor.prototype);
8870
- return elm;
8871
- };
8872
-
8873
- HTMLElementConstructor.prototype = HTMLElement.prototype;
8874
- }
8875
-
8876
9553
  function cloneNode(node, deep) {
8877
9554
  return node.cloneNode(deep);
8878
9555
  }
@@ -8931,18 +9608,18 @@
8931
9608
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
8932
9609
 
8933
9610
  if (!isUndefined(wrapperTags)) {
8934
- var _iterator6 = _createForOfIteratorHelper(wrapperTags),
8935
- _step6;
9611
+ var _iterator7 = _createForOfIteratorHelper(wrapperTags),
9612
+ _step7;
8936
9613
 
8937
9614
  try {
8938
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
8939
- var wrapperTag = _step6.value;
9615
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
9616
+ var wrapperTag = _step7.value;
8940
9617
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
8941
9618
  }
8942
9619
  } catch (err) {
8943
- _iterator6.e(err);
9620
+ _iterator7.e(err);
8944
9621
  } finally {
8945
- _iterator6.f();
9622
+ _iterator7.f();
8946
9623
  }
8947
9624
  } // For IE11, the document title must not be undefined, but it can be an empty string
8948
9625
  // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
@@ -9088,8 +9765,6 @@
9088
9765
  assert.invariant(elm instanceof HTMLElement, msg);
9089
9766
  }
9090
9767
 
9091
- var HTMLElementExported = HTMLElementConstructor;
9092
- exports.HTMLElementExported = HTMLElementExported;
9093
9768
  exports.addEventListener = addEventListener;
9094
9769
  exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
9095
9770
  exports.attachShadow = attachShadow;
@@ -9148,6 +9823,8 @@
9148
9823
  {
9149
9824
  // insertStyleSheet implementation shares a global cache of stylesheet data
9150
9825
  insertStylesheet: insertStylesheet,
9826
+ // relies on a shared global cache
9827
+ createCustomElement: createCustomElement,
9151
9828
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
9152
9829
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
9153
9830
  });
@@ -9268,35 +9945,39 @@
9268
9945
  var hydratedCustomElements = new WeakSet();
9269
9946
 
9270
9947
  function buildCustomElementConstructor(Ctor) {
9948
+ var _a;
9949
+
9271
9950
  var HtmlPrototype = getComponentHtmlPrototype(Ctor);
9272
- return /*#__PURE__*/function (_HtmlPrototype) {
9273
- _inherits(_class, _HtmlPrototype);
9951
+ var observedAttributes = HtmlPrototype.observedAttributes;
9952
+ var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
9953
+ return _a = /*#__PURE__*/function (_HTMLElement2) {
9954
+ _inherits(_a, _HTMLElement2);
9274
9955
 
9275
- var _super8 = _createSuper(_class);
9956
+ var _super10 = _createSuper(_a);
9276
9957
 
9277
- function _class() {
9278
- var _this6;
9958
+ function _a() {
9959
+ var _this8;
9279
9960
 
9280
- _classCallCheck(this, _class);
9961
+ _classCallCheck(this, _a);
9281
9962
 
9282
- _this6 = _super8.call(this);
9963
+ _this8 = _super10.call(this);
9283
9964
 
9284
- if (_this6.isConnected) {
9965
+ if (_this8.isConnected) {
9285
9966
  // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
9286
- hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
9287
- hydratedCustomElements.add(_assertThisInitialized(_this6));
9967
+ hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
9968
+ hydratedCustomElements.add(_assertThisInitialized(_this8));
9288
9969
  } else {
9289
- createVM(_assertThisInitialized(_this6), Ctor, renderer, {
9970
+ createVM(_assertThisInitialized(_this8), Ctor, renderer, {
9290
9971
  mode: 'open',
9291
9972
  owner: null,
9292
- tagName: _this6.tagName
9973
+ tagName: _this8.tagName
9293
9974
  });
9294
9975
  }
9295
9976
 
9296
- return _this6;
9977
+ return _this8;
9297
9978
  }
9298
9979
 
9299
- _createClass(_class, [{
9980
+ _createClass(_a, [{
9300
9981
  key: "connectedCallback",
9301
9982
  value: function connectedCallback() {
9302
9983
  if (hydratedCustomElements.has(this)) {
@@ -9311,10 +9992,15 @@
9311
9992
  value: function disconnectedCallback() {
9312
9993
  disconnectRootElement(this);
9313
9994
  }
9995
+ }, {
9996
+ key: "attributeChangedCallback",
9997
+ value: function attributeChangedCallback(name, oldValue, newValue) {
9998
+ _attributeChangedCallback.call(this, name, oldValue, newValue);
9999
+ }
9314
10000
  }]);
9315
10001
 
9316
- return _class;
9317
- }(HtmlPrototype);
10002
+ return _a;
10003
+ }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)), _a.observedAttributes = observedAttributes, _a;
9318
10004
  }
9319
10005
  /*
9320
10006
  * Copyright (c) 2018, salesforce.com, inc.
@@ -9400,8 +10086,11 @@
9400
10086
  throw new TypeError("\"createElement\" function expects an \"is\" option with a valid component constructor.");
9401
10087
  }
9402
10088
 
9403
- var UpgradableConstructor = getUpgradableConstructor(sel, renderer);
9404
- var wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
10089
+ var createCustomElement = renderer.createCustomElement; // tagName must be all lowercase, unfortunately, we have legacy code that is
10090
+ // passing `sel` as a camel-case, which makes them invalid custom elements name
10091
+ // the following line guarantees that this does not leaks beyond this point.
10092
+
10093
+ var tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
9405
10094
 
9406
10095
  /**
9407
10096
  * Note: if the upgradable constructor does not expect, or throw when we new it
@@ -9410,9 +10099,9 @@
9410
10099
  * an upgradable custom element.
9411
10100
  */
9412
10101
 
9413
- var element = new UpgradableConstructor(function (elm) {
10102
+ var upgradeCallback = function upgradeCallback(elm) {
9414
10103
  createVM(elm, Ctor, renderer, {
9415
- tagName: sel,
10104
+ tagName: tagName,
9416
10105
  mode: options.mode !== 'closed' ? 'open' : 'closed',
9417
10106
  owner: null
9418
10107
  });
@@ -9421,15 +10110,21 @@
9421
10110
  ConnectingSlot.set(elm, connectRootElement);
9422
10111
  DisconnectingSlot.set(elm, disconnectRootElement);
9423
10112
  }
10113
+ };
9424
10114
 
9425
- wasComponentUpgraded = true;
9426
- });
10115
+ var connectedCallback = function connectedCallback(elm) {
10116
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
10117
+ connectRootElement(elm);
10118
+ }
10119
+ };
9427
10120
 
9428
- if (!wasComponentUpgraded) {
9429
- /* eslint-disable-next-line no-console */
9430
- console.error("Unexpected tag name \"".concat(sel, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
9431
- }
10121
+ var disconnectedCallback = function disconnectedCallback(elm) {
10122
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
10123
+ disconnectRootElement(elm);
10124
+ }
10125
+ };
9432
10126
 
10127
+ var element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
9433
10128
  return element;
9434
10129
  }
9435
10130
  /*
@@ -9512,7 +10207,7 @@
9512
10207
  });
9513
10208
  freeze(LightningElement);
9514
10209
  seal(LightningElement.prototype);
9515
- /* version: 2.25.1 */
10210
+ /* version: 2.27.0 */
9516
10211
 
9517
10212
  exports.LightningElement = LightningElement;
9518
10213
  exports.__unstable__ProfilerControl = profilerControl;