lwc 2.23.1 → 2.23.2

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 +1182 -856
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1182 -855
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1101 -803
  5. package/dist/engine-dom/iife/es5/engine-dom.js +449 -368
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +409 -335
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1182 -855
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1101 -803
  11. package/dist/engine-dom/umd/es5/engine-dom.js +449 -368
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +409 -335
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +782 -521
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +782 -521
  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
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.23.1";
302
+ const LWC_VERSION = "2.23.2";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.23.1 */
304
+ /** version: 2.23.2 */
305
305
 
306
306
  /**
307
307
  * Copyright (C) 2018 salesforce.com, inc.
@@ -383,7 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
383
383
  patch$1(propName);
384
384
  }
385
385
  }
386
- /** version: 2.23.1 */
386
+ /** version: 2.23.2 */
387
387
 
388
388
  /**
389
389
  * Copyright (C) 2018 salesforce.com, inc.
@@ -403,6 +403,7 @@ const features = {
403
403
  ENABLE_HTML_COLLECTIONS_PATCH: null,
404
404
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
405
405
  ENABLE_MIXED_SHADOW_MODE: null,
406
+ ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
406
407
  ENABLE_NODE_LIST_PATCH: null,
407
408
  ENABLE_NODE_PATCH: null,
408
409
  ENABLE_REACTIVE_SETTER: null,
@@ -460,7 +461,7 @@ function setFeatureFlagForTest(name, value) {
460
461
  setFeatureFlag(name, value);
461
462
  }
462
463
  }
463
- /** version: 2.23.1 */
464
+ /** version: 2.23.2 */
464
465
 
465
466
  /*
466
467
  * Copyright (c) 2018, salesforce.com, inc.
@@ -809,8 +810,8 @@ function isCircularModuleDependency(obj) {
809
810
  */
810
811
  // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
811
812
  // to inject at runtime.
812
- const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
813
- const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
813
+ const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
814
+ const HTMLElementPrototype = HTMLElementConstructor.prototype;
814
815
 
815
816
  /*
816
817
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2887,7 +2888,7 @@ function HTMLBridgeElementFactory(SuperClass, props, methods) {
2887
2888
  defineProperties(HTMLBridgeElement.prototype, descriptors);
2888
2889
  return HTMLBridgeElement;
2889
2890
  }
2890
- const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2891
+ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2891
2892
  freeze(BaseBridgeElement);
2892
2893
  seal(BaseBridgeElement.prototype);
2893
2894
 
@@ -3546,30 +3547,67 @@ function createStylesheet(vm, stylesheets) {
3546
3547
  * SPDX-License-Identifier: MIT
3547
3548
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3548
3549
  */
3550
+
3551
+ function checkHasVM(elm) {
3552
+ const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
3553
+
3554
+ if (process.env.NODE_ENV !== 'production' && !hasVM) {
3555
+ // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
3556
+ // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
3557
+ logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
3558
+ }
3559
+
3560
+ return hasVM;
3561
+ }
3562
+
3549
3563
  function getUpgradableConstructor(tagName, renderer) {
3550
- const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3551
- // Should never get a tag with upper case letter at this point, the compiler should
3552
- // produce only tags with lowercase letters
3553
- // But, for backwards compatibility, we will lower case the tagName
3554
- tagName = tagName.toLowerCase();
3555
- let CE = getCustomElement(tagName);
3556
- if (!isUndefined$1(CE)) {
3557
- return CE;
3564
+ const {
3565
+ getCustomElement,
3566
+ HTMLElementExported: RendererHTMLElement,
3567
+ defineCustomElement
3568
+ } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
3569
+ // produce only tags with lowercase letters
3570
+ // But, for backwards compatibility, we will lower case the tagName
3571
+
3572
+ tagName = tagName.toLowerCase();
3573
+ let CE = getCustomElement(tagName);
3574
+
3575
+ if (!isUndefined$1(CE)) {
3576
+ return CE;
3577
+ }
3578
+ /**
3579
+ * LWC Upgradable Element reference to an element that was created
3580
+ * via the scoped registry mechanism, and that is ready to be upgraded.
3581
+ */
3582
+
3583
+
3584
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3585
+ constructor(upgradeCallback) {
3586
+ super();
3587
+
3588
+ if (isFunction$1(upgradeCallback)) {
3589
+ upgradeCallback(this); // nothing to do with the result for now
3590
+ }
3558
3591
  }
3559
- /**
3560
- * LWC Upgradable Element reference to an element that was created
3561
- * via the scoped registry mechanism, and that is ready to be upgraded.
3562
- */
3563
- CE = class LWCUpgradableElement extends RendererHTMLElement {
3564
- constructor(upgradeCallback) {
3565
- super();
3566
- if (isFunction$1(upgradeCallback)) {
3567
- upgradeCallback(this); // nothing to do with the result for now
3568
- }
3569
- }
3592
+
3593
+ };
3594
+
3595
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3596
+ CE.prototype.connectedCallback = function () {
3597
+ if (checkHasVM(this)) {
3598
+ connectRootElement(this);
3599
+ }
3570
3600
  };
3571
- defineCustomElement(tagName, CE);
3572
- return CE;
3601
+
3602
+ CE.prototype.disconnectedCallback = function () {
3603
+ if (checkHasVM(this)) {
3604
+ disconnectRootElement(this);
3605
+ }
3606
+ };
3607
+ }
3608
+
3609
+ defineCustomElement(tagName, CE);
3610
+ return CE;
3573
3611
  }
3574
3612
 
3575
3613
  /*
@@ -3657,6 +3695,14 @@ function patchProps(oldVnode, vnode, renderer) {
3657
3695
  // different than the one previously set.
3658
3696
  if (isFirstPatch ||
3659
3697
  cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3698
+ // Additional verification if properties are supported by the element
3699
+ // Validation relies on html properties and public properties being defined on the element,
3700
+ // SSR has its own custom validation.
3701
+ if (process.env.NODE_ENV !== 'production') {
3702
+ if (!(key in elm)) {
3703
+ logWarn(`Unknown public property "${key}" of element <${elm.tagName.toLowerCase()}>. This is either a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}", or the attribute does not exist in this browser or DOM implementation.`);
3704
+ }
3705
+ }
3660
3706
  setProperty(elm, key, cur);
3661
3707
  }
3662
3708
  }
@@ -3815,579 +3861,798 @@ function applyStaticStyleAttribute(vnode, renderer) {
3815
3861
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3816
3862
  */
3817
3863
  function patchChildren(c1, c2, parent, renderer) {
3818
- if (hasDynamicChildren(c2)) {
3819
- updateDynamicChildren(c1, c2, parent, renderer);
3820
- }
3821
- else {
3822
- updateStaticChildren(c1, c2, parent, renderer);
3823
- }
3864
+ if (hasDynamicChildren(c2)) {
3865
+ updateDynamicChildren(c1, c2, parent, renderer);
3866
+ } else {
3867
+ updateStaticChildren(c1, c2, parent, renderer);
3868
+ }
3824
3869
  }
3870
+
3825
3871
  function patch(n1, n2, parent, renderer) {
3826
- var _a, _b;
3827
- if (n1 === n2) {
3828
- return;
3829
- }
3830
- if (process.env.NODE_ENV !== 'production') {
3831
- if (!isSameVnode(n1, n2)) {
3832
- throw new Error('Expected these VNodes to be the same: ' +
3833
- JSON.stringify({ sel: n1.sel, key: n1.key }) +
3834
- ', ' +
3835
- JSON.stringify({ sel: n2.sel, key: n2.key }));
3836
- }
3837
- }
3838
- switch (n2.type) {
3839
- case 0 /* VNodeType.Text */:
3840
- // VText has no special capability, fallback to the owner's renderer
3841
- patchText(n1, n2, renderer);
3842
- break;
3843
- case 1 /* VNodeType.Comment */:
3844
- // VComment has no special capability, fallback to the owner's renderer
3845
- patchComment(n1, n2, renderer);
3846
- break;
3847
- case 4 /* VNodeType.Static */:
3848
- n2.elm = n1.elm;
3849
- break;
3850
- case 2 /* VNodeType.Element */:
3851
- patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3852
- break;
3853
- case 3 /* VNodeType.CustomElement */:
3854
- patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3855
- break;
3872
+ var _a, _b;
3873
+
3874
+ if (n1 === n2) {
3875
+ return;
3876
+ }
3877
+
3878
+ if (process.env.NODE_ENV !== 'production') {
3879
+ if (!isSameVnode(n1, n2)) {
3880
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
3881
+ sel: n1.sel,
3882
+ key: n1.key
3883
+ }) + ', ' + JSON.stringify({
3884
+ sel: n2.sel,
3885
+ key: n2.key
3886
+ }));
3856
3887
  }
3888
+ }
3889
+
3890
+ switch (n2.type) {
3891
+ case 0
3892
+ /* VNodeType.Text */
3893
+ :
3894
+ // VText has no special capability, fallback to the owner's renderer
3895
+ patchText(n1, n2, renderer);
3896
+ break;
3897
+
3898
+ case 1
3899
+ /* VNodeType.Comment */
3900
+ :
3901
+ // VComment has no special capability, fallback to the owner's renderer
3902
+ patchComment(n1, n2, renderer);
3903
+ break;
3904
+
3905
+ case 4
3906
+ /* VNodeType.Static */
3907
+ :
3908
+ n2.elm = n1.elm;
3909
+ break;
3910
+
3911
+ case 2
3912
+ /* VNodeType.Element */
3913
+ :
3914
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3915
+ break;
3916
+
3917
+ case 3
3918
+ /* VNodeType.CustomElement */
3919
+ :
3920
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3921
+ break;
3922
+ }
3857
3923
  }
3924
+
3858
3925
  function mount(node, parent, renderer, anchor) {
3859
- var _a, _b;
3860
- switch (node.type) {
3861
- case 0 /* VNodeType.Text */:
3862
- // VText has no special capability, fallback to the owner's renderer
3863
- mountText(node, parent, anchor, renderer);
3864
- break;
3865
- case 1 /* VNodeType.Comment */:
3866
- // VComment has no special capability, fallback to the owner's renderer
3867
- mountComment(node, parent, anchor, renderer);
3868
- break;
3869
- case 4 /* VNodeType.Static */:
3870
- // VStatic cannot have a custom renderer associated to them, using owner's renderer
3871
- mountStatic(node, parent, anchor, renderer);
3872
- break;
3873
- case 2 /* VNodeType.Element */:
3874
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3875
- mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3876
- break;
3877
- case 3 /* VNodeType.CustomElement */:
3878
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3879
- mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3880
- break;
3881
- }
3926
+ var _a, _b;
3927
+
3928
+ switch (node.type) {
3929
+ case 0
3930
+ /* VNodeType.Text */
3931
+ :
3932
+ // VText has no special capability, fallback to the owner's renderer
3933
+ mountText(node, parent, anchor, renderer);
3934
+ break;
3935
+
3936
+ case 1
3937
+ /* VNodeType.Comment */
3938
+ :
3939
+ // VComment has no special capability, fallback to the owner's renderer
3940
+ mountComment(node, parent, anchor, renderer);
3941
+ break;
3942
+
3943
+ case 4
3944
+ /* VNodeType.Static */
3945
+ :
3946
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3947
+ mountStatic(node, parent, anchor, renderer);
3948
+ break;
3949
+
3950
+ case 2
3951
+ /* VNodeType.Element */
3952
+ :
3953
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3954
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3955
+ break;
3956
+
3957
+ case 3
3958
+ /* VNodeType.CustomElement */
3959
+ :
3960
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3961
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3962
+ break;
3963
+ }
3882
3964
  }
3965
+
3883
3966
  function patchText(n1, n2, renderer) {
3884
- n2.elm = n1.elm;
3885
- if (n2.text !== n1.text) {
3886
- updateTextContent(n2, renderer);
3887
- }
3967
+ n2.elm = n1.elm;
3968
+
3969
+ if (n2.text !== n1.text) {
3970
+ updateTextContent(n2, renderer);
3971
+ }
3888
3972
  }
3973
+
3889
3974
  function mountText(vnode, parent, anchor, renderer) {
3890
- const { owner } = vnode;
3891
- const { createText } = renderer;
3892
- const textNode = (vnode.elm = createText(vnode.text));
3893
- linkNodeToShadow(textNode, owner, renderer);
3894
- insertNode(textNode, parent, anchor, renderer);
3975
+ const {
3976
+ owner
3977
+ } = vnode;
3978
+ const {
3979
+ createText
3980
+ } = renderer;
3981
+ const textNode = vnode.elm = createText(vnode.text);
3982
+ linkNodeToShadow(textNode, owner, renderer);
3983
+ insertNode(textNode, parent, anchor, renderer);
3895
3984
  }
3985
+
3896
3986
  function patchComment(n1, n2, renderer) {
3897
- n2.elm = n1.elm;
3898
- // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3899
- // it is the case today.
3900
- if (n2.text !== n1.text) {
3901
- updateTextContent(n2, renderer);
3902
- }
3987
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3988
+ // it is the case today.
3989
+
3990
+ if (n2.text !== n1.text) {
3991
+ updateTextContent(n2, renderer);
3992
+ }
3903
3993
  }
3994
+
3904
3995
  function mountComment(vnode, parent, anchor, renderer) {
3905
- const { owner } = vnode;
3906
- const { createComment } = renderer;
3907
- const commentNode = (vnode.elm = createComment(vnode.text));
3908
- linkNodeToShadow(commentNode, owner, renderer);
3909
- insertNode(commentNode, parent, anchor, renderer);
3996
+ const {
3997
+ owner
3998
+ } = vnode;
3999
+ const {
4000
+ createComment
4001
+ } = renderer;
4002
+ const commentNode = vnode.elm = createComment(vnode.text);
4003
+ linkNodeToShadow(commentNode, owner, renderer);
4004
+ insertNode(commentNode, parent, anchor, renderer);
3910
4005
  }
4006
+
3911
4007
  function mountElement(vnode, parent, anchor, renderer) {
3912
- const { sel, owner, data: { svg }, } = vnode;
3913
- const { createElement } = renderer;
3914
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3915
- const elm = (vnode.elm = createElement(sel, namespace));
3916
- linkNodeToShadow(elm, owner, renderer);
3917
- applyStyleScoping(elm, owner, renderer);
3918
- applyDomManual(elm, vnode);
3919
- applyElementRestrictions(elm, vnode);
3920
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3921
- insertNode(elm, parent, anchor, renderer);
3922
- mountVNodes(vnode.children, elm, renderer, null);
4008
+ const {
4009
+ sel,
4010
+ owner,
4011
+ data: {
4012
+ svg
4013
+ }
4014
+ } = vnode;
4015
+ const {
4016
+ createElement
4017
+ } = renderer;
4018
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4019
+ const elm = vnode.elm = createElement(sel, namespace);
4020
+ linkNodeToShadow(elm, owner, renderer);
4021
+ applyStyleScoping(elm, owner, renderer);
4022
+ applyDomManual(elm, vnode);
4023
+ applyElementRestrictions(elm, vnode);
4024
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
4025
+ insertNode(elm, parent, anchor, renderer);
4026
+ mountVNodes(vnode.children, elm, renderer, null);
3923
4027
  }
4028
+
3924
4029
  function patchElement(n1, n2, renderer) {
3925
- const elm = (n2.elm = n1.elm);
3926
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3927
- patchChildren(n1.children, n2.children, elm, renderer);
4030
+ const elm = n2.elm = n1.elm;
4031
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
4032
+ patchChildren(n1.children, n2.children, elm, renderer);
3928
4033
  }
4034
+
3929
4035
  function mountStatic(vnode, parent, anchor, renderer) {
3930
- const { owner } = vnode;
3931
- const { cloneNode, isSyntheticShadowDefined } = renderer;
3932
- const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3933
- linkNodeToShadow(elm, owner, renderer);
3934
- applyElementRestrictions(elm, vnode);
3935
- // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3936
- const { renderMode, shadowMode } = owner;
3937
- if (isSyntheticShadowDefined) {
3938
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3939
- elm[KEY__SHADOW_STATIC] = true;
3940
- }
4036
+ const {
4037
+ owner
4038
+ } = vnode;
4039
+ const {
4040
+ cloneNode,
4041
+ isSyntheticShadowDefined
4042
+ } = renderer;
4043
+ const elm = vnode.elm = cloneNode(vnode.fragment, true);
4044
+ linkNodeToShadow(elm, owner, renderer);
4045
+ applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
4046
+
4047
+ const {
4048
+ renderMode,
4049
+ shadowMode
4050
+ } = owner;
4051
+
4052
+ if (isSyntheticShadowDefined) {
4053
+ if (shadowMode === 1
4054
+ /* ShadowMode.Synthetic */
4055
+ || renderMode === 0
4056
+ /* RenderMode.Light */
4057
+ ) {
4058
+ elm[KEY__SHADOW_STATIC] = true;
3941
4059
  }
3942
- insertNode(elm, parent, anchor, renderer);
4060
+ }
4061
+
4062
+ insertNode(elm, parent, anchor, renderer);
3943
4063
  }
4064
+
3944
4065
  function mountCustomElement(vnode, parent, anchor, renderer) {
3945
- const { sel, owner } = vnode;
3946
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3947
- /**
3948
- * Note: if the upgradable constructor does not expect, or throw when we new it
3949
- * with a callback as the first argument, we could implement a more advanced
3950
- * mechanism that only passes that argument if the constructor is known to be
3951
- * an upgradable custom element.
3952
- */
3953
- let vm;
3954
- const elm = new UpgradableConstructor((elm) => {
3955
- // the custom element from the registry is expecting an upgrade callback
3956
- vm = createViewModelHook(elm, vnode, renderer);
3957
- });
3958
- vnode.elm = elm;
3959
- vnode.vm = vm;
3960
- linkNodeToShadow(elm, owner, renderer);
3961
- applyStyleScoping(elm, owner, renderer);
3962
- if (vm) {
3963
- allocateChildren(vnode, vm);
3964
- }
3965
- else if (vnode.ctor !== UpgradableConstructor) {
3966
- throw new TypeError(`Incorrect Component Constructor`);
3967
- }
3968
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3969
- insertNode(elm, parent, anchor, renderer);
3970
- if (vm) {
4066
+ const {
4067
+ sel,
4068
+ owner
4069
+ } = vnode;
4070
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
4071
+ /**
4072
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4073
+ * with a callback as the first argument, we could implement a more advanced
4074
+ * mechanism that only passes that argument if the constructor is known to be
4075
+ * an upgradable custom element.
4076
+ */
4077
+
4078
+ let vm;
4079
+ const elm = new UpgradableConstructor(elm => {
4080
+ // the custom element from the registry is expecting an upgrade callback
4081
+ vm = createViewModelHook(elm, vnode, renderer);
4082
+ });
4083
+ vnode.elm = elm;
4084
+ vnode.vm = vm;
4085
+ linkNodeToShadow(elm, owner, renderer);
4086
+ applyStyleScoping(elm, owner, renderer);
4087
+
4088
+ if (vm) {
4089
+ allocateChildren(vnode, vm);
4090
+ } else if (vnode.ctor !== UpgradableConstructor) {
4091
+ throw new TypeError(`Incorrect Component Constructor`);
4092
+ }
4093
+
4094
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
4095
+ insertNode(elm, parent, anchor, renderer);
4096
+
4097
+ if (vm) {
4098
+ {
4099
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3971
4100
  if (process.env.NODE_ENV !== 'production') {
3972
- assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
4101
+ // With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
4102
+ // noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
4103
+ assert.isTrue(vm.state === 0
4104
+ /* VMState.created */
4105
+ , `${vm} cannot be recycled.`);
3973
4106
  }
4107
+
3974
4108
  runConnectedCallback(vm);
4109
+ }
3975
4110
  }
3976
- mountVNodes(vnode.children, elm, renderer, null);
3977
- if (vm) {
3978
- appendVM(vm);
3979
- }
4111
+ }
4112
+
4113
+ mountVNodes(vnode.children, elm, renderer, null);
4114
+
4115
+ if (vm) {
4116
+ appendVM(vm);
4117
+ }
3980
4118
  }
4119
+
3981
4120
  function patchCustomElement(n1, n2, parent, renderer) {
3982
- if (n1.ctor !== n2.ctor) {
3983
- // If the constructor, unmount the current component and mount a new one using the new
3984
- // constructor.
3985
- const anchor = renderer.nextSibling(n1.elm);
3986
- unmount(n1, parent, renderer, true);
3987
- mountCustomElement(n2, parent, anchor, renderer);
3988
- }
3989
- else {
3990
- // Otherwise patch the existing component with new props/attrs/etc.
3991
- const elm = (n2.elm = n1.elm);
3992
- const vm = (n2.vm = n1.vm);
3993
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3994
- if (!isUndefined$1(vm)) {
3995
- // in fallback mode, the allocation will always set children to
3996
- // empty and delegate the real allocation to the slot elements
3997
- allocateChildren(n2, vm);
3998
- }
3999
- // in fallback mode, the children will be always empty, so, nothing
4000
- // will happen, but in native, it does allocate the light dom
4001
- patchChildren(n1.children, n2.children, elm, renderer);
4002
- if (!isUndefined$1(vm)) {
4003
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
4004
- // this is important to preserve the top to bottom synchronous rendering phase.
4005
- rerenderVM(vm);
4006
- }
4121
+ if (n1.ctor !== n2.ctor) {
4122
+ // If the constructor, unmount the current component and mount a new one using the new
4123
+ // constructor.
4124
+ const anchor = renderer.nextSibling(n1.elm);
4125
+ unmount(n1, parent, renderer, true);
4126
+ mountCustomElement(n2, parent, anchor, renderer);
4127
+ } else {
4128
+ // Otherwise patch the existing component with new props/attrs/etc.
4129
+ const elm = n2.elm = n1.elm;
4130
+ const vm = n2.vm = n1.vm;
4131
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
4132
+
4133
+ if (!isUndefined$1(vm)) {
4134
+ // in fallback mode, the allocation will always set children to
4135
+ // empty and delegate the real allocation to the slot elements
4136
+ allocateChildren(n2, vm);
4137
+ } // in fallback mode, the children will be always empty, so, nothing
4138
+ // will happen, but in native, it does allocate the light dom
4139
+
4140
+
4141
+ patchChildren(n1.children, n2.children, elm, renderer);
4142
+
4143
+ if (!isUndefined$1(vm)) {
4144
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4145
+ // this is important to preserve the top to bottom synchronous rendering phase.
4146
+ rerenderVM(vm);
4007
4147
  }
4148
+ }
4008
4149
  }
4150
+
4009
4151
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
4010
- for (; start < end; ++start) {
4011
- const vnode = vnodes[start];
4012
- if (isVNode(vnode)) {
4013
- mount(vnode, parent, renderer, anchor);
4014
- }
4152
+ for (; start < end; ++start) {
4153
+ const vnode = vnodes[start];
4154
+
4155
+ if (isVNode(vnode)) {
4156
+ mount(vnode, parent, renderer, anchor);
4015
4157
  }
4158
+ }
4016
4159
  }
4160
+
4017
4161
  function unmount(vnode, parent, renderer, doRemove = false) {
4018
- const { type, elm, sel } = vnode;
4019
- // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4020
- // subtree root, is the only element worth unmounting from the subtree.
4021
- if (doRemove) {
4022
- // The vnode might or might not have a data.renderer associated to it
4023
- // but the removal used here is from the owner instead.
4024
- removeNode(elm, parent, renderer);
4025
- }
4026
- switch (type) {
4027
- case 2 /* VNodeType.Element */: {
4028
- // Slot content is removed to trigger slotchange event when removing slot.
4029
- // Only required for synthetic shadow.
4030
- const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4031
- unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
4032
- break;
4033
- }
4034
- case 3 /* VNodeType.CustomElement */: {
4035
- const { vm } = vnode;
4036
- // No need to unmount the children here, `removeVM` will take care of removing the
4037
- // children.
4038
- if (!isUndefined$1(vm)) {
4039
- removeVM(vm);
4040
- }
4162
+ const {
4163
+ type,
4164
+ elm,
4165
+ sel
4166
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4167
+ // subtree root, is the only element worth unmounting from the subtree.
4168
+
4169
+ if (doRemove) {
4170
+ // The vnode might or might not have a data.renderer associated to it
4171
+ // but the removal used here is from the owner instead.
4172
+ removeNode(elm, parent, renderer);
4173
+ }
4174
+
4175
+ switch (type) {
4176
+ case 2
4177
+ /* VNodeType.Element */
4178
+ :
4179
+ {
4180
+ // Slot content is removed to trigger slotchange event when removing slot.
4181
+ // Only required for synthetic shadow.
4182
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
4183
+ /* ShadowMode.Synthetic */
4184
+ ;
4185
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
4186
+ break;
4187
+ }
4188
+
4189
+ case 3
4190
+ /* VNodeType.CustomElement */
4191
+ :
4192
+ {
4193
+ const {
4194
+ vm
4195
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
4196
+ // children.
4197
+
4198
+ if (!isUndefined$1(vm)) {
4199
+ removeVM(vm);
4041
4200
  }
4042
- }
4201
+ }
4202
+ }
4043
4203
  }
4204
+
4044
4205
  function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
4045
- for (; start < end; ++start) {
4046
- const ch = vnodes[start];
4047
- if (isVNode(ch)) {
4048
- unmount(ch, parent, renderer, doRemove);
4049
- }
4206
+ for (; start < end; ++start) {
4207
+ const ch = vnodes[start];
4208
+
4209
+ if (isVNode(ch)) {
4210
+ unmount(ch, parent, renderer, doRemove);
4050
4211
  }
4212
+ }
4051
4213
  }
4214
+
4052
4215
  function isVNode(vnode) {
4053
- return vnode != null;
4216
+ return vnode != null;
4054
4217
  }
4218
+
4055
4219
  function linkNodeToShadow(elm, owner, renderer) {
4056
- const { renderRoot, renderMode, shadowMode } = owner;
4057
- const { isSyntheticShadowDefined } = renderer;
4058
- // TODO [#1164]: this should eventually be done by the polyfill directly
4059
- if (isSyntheticShadowDefined) {
4060
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
4061
- elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
4062
- }
4220
+ const {
4221
+ renderRoot,
4222
+ renderMode,
4223
+ shadowMode
4224
+ } = owner;
4225
+ const {
4226
+ isSyntheticShadowDefined
4227
+ } = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
4228
+
4229
+ if (isSyntheticShadowDefined) {
4230
+ if (shadowMode === 1
4231
+ /* ShadowMode.Synthetic */
4232
+ || renderMode === 0
4233
+ /* RenderMode.Light */
4234
+ ) {
4235
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
4063
4236
  }
4237
+ }
4064
4238
  }
4239
+
4065
4240
  function updateTextContent(vnode, renderer) {
4066
- const { elm, text } = vnode;
4067
- const { setText } = renderer;
4068
- if (process.env.NODE_ENV !== 'production') {
4069
- unlockDomMutation();
4070
- }
4071
- setText(elm, text);
4072
- if (process.env.NODE_ENV !== 'production') {
4073
- lockDomMutation();
4074
- }
4241
+ const {
4242
+ elm,
4243
+ text
4244
+ } = vnode;
4245
+ const {
4246
+ setText
4247
+ } = renderer;
4248
+
4249
+ if (process.env.NODE_ENV !== 'production') {
4250
+ unlockDomMutation();
4251
+ }
4252
+
4253
+ setText(elm, text);
4254
+
4255
+ if (process.env.NODE_ENV !== 'production') {
4256
+ lockDomMutation();
4257
+ }
4075
4258
  }
4259
+
4076
4260
  function insertNode(node, parent, anchor, renderer) {
4077
- if (process.env.NODE_ENV !== 'production') {
4078
- unlockDomMutation();
4079
- }
4080
- renderer.insert(node, parent, anchor);
4081
- if (process.env.NODE_ENV !== 'production') {
4082
- lockDomMutation();
4083
- }
4261
+ if (process.env.NODE_ENV !== 'production') {
4262
+ unlockDomMutation();
4263
+ }
4264
+
4265
+ renderer.insert(node, parent, anchor);
4266
+
4267
+ if (process.env.NODE_ENV !== 'production') {
4268
+ lockDomMutation();
4269
+ }
4084
4270
  }
4271
+
4085
4272
  function removeNode(node, parent, renderer) {
4086
- if (process.env.NODE_ENV !== 'production') {
4087
- unlockDomMutation();
4088
- }
4089
- renderer.remove(node, parent);
4090
- if (process.env.NODE_ENV !== 'production') {
4091
- lockDomMutation();
4092
- }
4273
+ if (process.env.NODE_ENV !== 'production') {
4274
+ unlockDomMutation();
4275
+ }
4276
+
4277
+ renderer.remove(node, parent);
4278
+
4279
+ if (process.env.NODE_ENV !== 'production') {
4280
+ lockDomMutation();
4281
+ }
4093
4282
  }
4283
+
4094
4284
  function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
4095
- if (isNull(oldVnode)) {
4096
- applyEventListeners(vnode, renderer);
4097
- applyStaticClassAttribute(vnode, renderer);
4098
- applyStaticStyleAttribute(vnode, renderer);
4099
- }
4100
- // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4101
- // value is set before type=radio.
4102
- patchClassAttribute(oldVnode, vnode, renderer);
4103
- patchStyleAttribute(oldVnode, vnode, renderer);
4104
- patchAttributes(oldVnode, vnode, renderer);
4105
- patchProps(oldVnode, vnode, renderer);
4285
+ if (isNull(oldVnode)) {
4286
+ applyEventListeners(vnode, renderer);
4287
+ applyStaticClassAttribute(vnode, renderer);
4288
+ applyStaticStyleAttribute(vnode, renderer);
4289
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4290
+ // value is set before type=radio.
4291
+
4292
+
4293
+ patchClassAttribute(oldVnode, vnode, renderer);
4294
+ patchStyleAttribute(oldVnode, vnode, renderer);
4295
+ patchAttributes(oldVnode, vnode, renderer);
4296
+ patchProps(oldVnode, vnode, renderer);
4106
4297
  }
4298
+
4107
4299
  function applyStyleScoping(elm, owner, renderer) {
4108
- // Set the class name for `*.scoped.css` style scoping.
4109
- const scopeToken = getScopeTokenClass(owner);
4110
- if (!isNull(scopeToken)) {
4111
- const { getClassList } = renderer;
4112
- // TODO [#2762]: this dot notation with add is probably problematic
4113
- // probably we should have a renderer api for just the add operation
4114
- getClassList(elm).add(scopeToken);
4115
- }
4116
- // Set property element for synthetic shadow DOM style scoping.
4117
- const { stylesheetToken: syntheticToken } = owner.context;
4118
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
4119
- elm.$shadowToken$ = syntheticToken;
4120
- }
4300
+ // Set the class name for `*.scoped.css` style scoping.
4301
+ const scopeToken = getScopeTokenClass(owner);
4302
+
4303
+ if (!isNull(scopeToken)) {
4304
+ const {
4305
+ getClassList
4306
+ } = renderer; // TODO [#2762]: this dot notation with add is probably problematic
4307
+ // probably we should have a renderer api for just the add operation
4308
+
4309
+ getClassList(elm).add(scopeToken);
4310
+ } // Set property element for synthetic shadow DOM style scoping.
4311
+
4312
+
4313
+ const {
4314
+ stylesheetToken: syntheticToken
4315
+ } = owner.context;
4316
+
4317
+ if (owner.shadowMode === 1
4318
+ /* ShadowMode.Synthetic */
4319
+ && !isUndefined$1(syntheticToken)) {
4320
+ elm.$shadowToken$ = syntheticToken;
4321
+ }
4121
4322
  }
4323
+
4122
4324
  function applyDomManual(elm, vnode) {
4123
- var _a;
4124
- const { owner, data: { context }, } = vnode;
4125
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
4126
- elm.$domManual$ = true;
4325
+ var _a;
4326
+
4327
+ const {
4328
+ owner,
4329
+ data: {
4330
+ context
4127
4331
  }
4332
+ } = vnode;
4333
+
4334
+ if (owner.shadowMode === 1
4335
+ /* ShadowMode.Synthetic */
4336
+ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
4337
+ /* LwcDomMode.Manual */
4338
+ ) {
4339
+ elm.$domManual$ = true;
4340
+ }
4128
4341
  }
4342
+
4129
4343
  function applyElementRestrictions(elm, vnode) {
4130
- var _a, _b;
4131
- if (process.env.NODE_ENV !== 'production') {
4132
- const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
4133
- const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4134
- patchElementWithRestrictions(elm, {
4135
- isPortal,
4136
- isLight,
4137
- });
4138
- }
4344
+ var _a, _b;
4345
+
4346
+ if (process.env.NODE_ENV !== 'production') {
4347
+ const isPortal = vnode.type === 2
4348
+ /* VNodeType.Element */
4349
+ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
4350
+ /* LwcDomMode.Manual */
4351
+ ;
4352
+ const isLight = vnode.owner.renderMode === 0
4353
+ /* RenderMode.Light */
4354
+ ;
4355
+ patchElementWithRestrictions(elm, {
4356
+ isPortal,
4357
+ isLight
4358
+ });
4359
+ }
4139
4360
  }
4361
+
4140
4362
  function allocateChildren(vnode, vm) {
4141
- // A component with slots will re-render because:
4142
- // 1- There is a change of the internal state.
4143
- // 2- There is a change on the external api (ex: slots)
4144
- //
4145
- // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
4146
- // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
4147
- // in a reused VCustomElement, there won't be any slotted children.
4148
- // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
4149
- //
4150
- // In case #2, we will always get a fresh VCustomElement.
4151
- const children = vnode.aChildren || vnode.children;
4152
- vm.aChildren = children;
4153
- const { renderMode, shadowMode } = vm;
4154
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
4155
- // slow path
4156
- allocateInSlot(vm, children);
4157
- // save the allocated children in case this vnode is reused.
4158
- vnode.aChildren = children;
4159
- // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4160
- vnode.children = EmptyArray;
4161
- }
4363
+ // A component with slots will re-render because:
4364
+ // 1- There is a change of the internal state.
4365
+ // 2- There is a change on the external api (ex: slots)
4366
+ //
4367
+ // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
4368
+ // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
4369
+ // in a reused VCustomElement, there won't be any slotted children.
4370
+ // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
4371
+ //
4372
+ // In case #2, we will always get a fresh VCustomElement.
4373
+ const children = vnode.aChildren || vnode.children;
4374
+ vm.aChildren = children;
4375
+ const {
4376
+ renderMode,
4377
+ shadowMode
4378
+ } = vm;
4379
+
4380
+ if (shadowMode === 1
4381
+ /* ShadowMode.Synthetic */
4382
+ || renderMode === 0
4383
+ /* RenderMode.Light */
4384
+ ) {
4385
+ // slow path
4386
+ allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4387
+
4388
+ vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4389
+
4390
+ vnode.children = EmptyArray;
4391
+ }
4162
4392
  }
4393
+
4163
4394
  function createViewModelHook(elm, vnode, renderer) {
4164
- let vm = getAssociatedVMIfPresent(elm);
4165
- // There is a possibility that a custom element is registered under tagName, in which case, the
4166
- // initialization is already carry on, and there is nothing else to do here since this hook is
4167
- // called right after invoking `document.createElement`.
4168
- if (!isUndefined$1(vm)) {
4169
- return vm;
4395
+ let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
4396
+ // initialization is already carry on, and there is nothing else to do here since this hook is
4397
+ // called right after invoking `document.createElement`.
4398
+
4399
+ if (!isUndefined$1(vm)) {
4400
+ return vm;
4401
+ }
4402
+
4403
+ const {
4404
+ sel,
4405
+ mode,
4406
+ ctor,
4407
+ owner
4408
+ } = vnode;
4409
+ vm = createVM(elm, ctor, renderer, {
4410
+ mode,
4411
+ owner,
4412
+ tagName: sel
4413
+ });
4414
+
4415
+ if (process.env.NODE_ENV !== 'production') {
4416
+ assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4417
+ }
4418
+
4419
+ return vm;
4420
+ }
4421
+
4422
+ function allocateInSlot(vm, children) {
4423
+ var _a;
4424
+
4425
+ const {
4426
+ cmpSlots: oldSlots
4427
+ } = vm;
4428
+ const cmpSlots = vm.cmpSlots = create(null);
4429
+
4430
+ for (let i = 0, len = children.length; i < len; i += 1) {
4431
+ const vnode = children[i];
4432
+
4433
+ if (isNull(vnode)) {
4434
+ continue;
4435
+ }
4436
+
4437
+ let slotName = '';
4438
+
4439
+ if (isVBaseElement(vnode)) {
4440
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4170
4441
  }
4171
- const { sel, mode, ctor, owner } = vnode;
4172
- vm = createVM(elm, ctor, renderer, {
4173
- mode,
4174
- owner,
4175
- tagName: sel,
4176
- });
4177
- if (process.env.NODE_ENV !== 'production') {
4178
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4442
+
4443
+ const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4444
+ ArrayPush$1.call(vnodes, vnode);
4445
+ }
4446
+
4447
+ if (isFalse(vm.isDirty)) {
4448
+ // We need to determine if the old allocation is really different from the new one
4449
+ // and mark the vm as dirty
4450
+ const oldKeys = keys(oldSlots);
4451
+
4452
+ if (oldKeys.length !== keys(cmpSlots).length) {
4453
+ markComponentAsDirty(vm);
4454
+ return;
4179
4455
  }
4180
- return vm;
4181
- }
4182
- function allocateInSlot(vm, children) {
4183
- var _a;
4184
- const { cmpSlots: oldSlots } = vm;
4185
- const cmpSlots = (vm.cmpSlots = create(null));
4186
- for (let i = 0, len = children.length; i < len; i += 1) {
4187
- const vnode = children[i];
4188
- if (isNull(vnode)) {
4189
- continue;
4190
- }
4191
- let slotName = '';
4192
- if (isVBaseElement(vnode)) {
4193
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4194
- }
4195
- const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
4196
- ArrayPush$1.call(vnodes, vnode);
4197
- }
4198
- if (isFalse(vm.isDirty)) {
4199
- // We need to determine if the old allocation is really different from the new one
4200
- // and mark the vm as dirty
4201
- const oldKeys = keys(oldSlots);
4202
- if (oldKeys.length !== keys(cmpSlots).length) {
4203
- markComponentAsDirty(vm);
4204
- return;
4205
- }
4206
- for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4207
- const key = oldKeys[i];
4208
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4209
- markComponentAsDirty(vm);
4210
- return;
4211
- }
4212
- const oldVNodes = oldSlots[key];
4213
- const vnodes = cmpSlots[key];
4214
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4215
- if (oldVNodes[j] !== vnodes[j]) {
4216
- markComponentAsDirty(vm);
4217
- return;
4218
- }
4219
- }
4456
+
4457
+ for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4458
+ const key = oldKeys[i];
4459
+
4460
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4461
+ markComponentAsDirty(vm);
4462
+ return;
4463
+ }
4464
+
4465
+ const oldVNodes = oldSlots[key];
4466
+ const vnodes = cmpSlots[key];
4467
+
4468
+ for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4469
+ if (oldVNodes[j] !== vnodes[j]) {
4470
+ markComponentAsDirty(vm);
4471
+ return;
4220
4472
  }
4473
+ }
4221
4474
  }
4222
- }
4223
- // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4224
- const FromIteration = new WeakMap();
4225
- // dynamic children means it was generated by an iteration
4475
+ }
4476
+ } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4477
+
4478
+
4479
+ const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
4226
4480
  // in a template, and will require a more complex diffing algo.
4481
+
4227
4482
  function markAsDynamicChildren(children) {
4228
- FromIteration.set(children, 1);
4483
+ FromIteration.set(children, 1);
4229
4484
  }
4485
+
4230
4486
  function hasDynamicChildren(children) {
4231
- return FromIteration.has(children);
4487
+ return FromIteration.has(children);
4232
4488
  }
4489
+
4233
4490
  function createKeyToOldIdx(children, beginIdx, endIdx) {
4234
- const map = {};
4235
- // TODO [#1637]: simplify this by assuming that all vnodes has keys
4236
- for (let j = beginIdx; j <= endIdx; ++j) {
4237
- const ch = children[j];
4238
- if (isVNode(ch)) {
4239
- const { key } = ch;
4240
- if (key !== undefined) {
4241
- map[key] = j;
4242
- }
4243
- }
4491
+ const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
4492
+
4493
+ for (let j = beginIdx; j <= endIdx; ++j) {
4494
+ const ch = children[j];
4495
+
4496
+ if (isVNode(ch)) {
4497
+ const {
4498
+ key
4499
+ } = ch;
4500
+
4501
+ if (key !== undefined) {
4502
+ map[key] = j;
4503
+ }
4244
4504
  }
4245
- return map;
4505
+ }
4506
+
4507
+ return map;
4246
4508
  }
4509
+
4247
4510
  function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4248
- let oldStartIdx = 0;
4249
- let newStartIdx = 0;
4250
- let oldEndIdx = oldCh.length - 1;
4251
- let oldStartVnode = oldCh[0];
4252
- let oldEndVnode = oldCh[oldEndIdx];
4253
- const newChEnd = newCh.length - 1;
4254
- let newEndIdx = newChEnd;
4255
- let newStartVnode = newCh[0];
4256
- let newEndVnode = newCh[newEndIdx];
4257
- let oldKeyToIdx;
4258
- let idxInOld;
4259
- let elmToMove;
4260
- let before;
4261
- let clonedOldCh = false;
4262
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4263
- if (!isVNode(oldStartVnode)) {
4264
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
4265
- }
4266
- else if (!isVNode(oldEndVnode)) {
4267
- oldEndVnode = oldCh[--oldEndIdx];
4268
- }
4269
- else if (!isVNode(newStartVnode)) {
4270
- newStartVnode = newCh[++newStartIdx];
4271
- }
4272
- else if (!isVNode(newEndVnode)) {
4273
- newEndVnode = newCh[--newEndIdx];
4274
- }
4275
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
4276
- patch(oldStartVnode, newStartVnode, parent, renderer);
4277
- oldStartVnode = oldCh[++oldStartIdx];
4278
- newStartVnode = newCh[++newStartIdx];
4279
- }
4280
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
4281
- patch(oldEndVnode, newEndVnode, parent, renderer);
4282
- oldEndVnode = oldCh[--oldEndIdx];
4283
- newEndVnode = newCh[--newEndIdx];
4284
- }
4285
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
4286
- // Vnode moved right
4287
- patch(oldStartVnode, newEndVnode, parent, renderer);
4288
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4289
- oldStartVnode = oldCh[++oldStartIdx];
4290
- newEndVnode = newCh[--newEndIdx];
4291
- }
4292
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
4293
- // Vnode moved left
4294
- patch(oldEndVnode, newStartVnode, parent, renderer);
4295
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4296
- oldEndVnode = oldCh[--oldEndIdx];
4297
- newStartVnode = newCh[++newStartIdx];
4298
- }
4299
- else {
4300
- if (oldKeyToIdx === undefined) {
4301
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4302
- }
4303
- idxInOld = oldKeyToIdx[newStartVnode.key];
4304
- if (isUndefined$1(idxInOld)) {
4305
- // New element
4306
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4307
- newStartVnode = newCh[++newStartIdx];
4308
- }
4309
- else {
4310
- elmToMove = oldCh[idxInOld];
4311
- if (isVNode(elmToMove)) {
4312
- if (elmToMove.sel !== newStartVnode.sel) {
4313
- // New element
4314
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4315
- }
4316
- else {
4317
- patch(elmToMove, newStartVnode, parent, renderer);
4318
- // Delete the old child, but copy the array since it is read-only.
4319
- // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4320
- // so we only care about the `oldCh` object inside this function.
4321
- // To avoid cloning over and over again, we check `clonedOldCh`
4322
- // and only clone once.
4323
- if (!clonedOldCh) {
4324
- clonedOldCh = true;
4325
- oldCh = [...oldCh];
4326
- }
4327
- // We've already cloned at least once, so it's no longer read-only
4328
- oldCh[idxInOld] = undefined;
4329
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4330
- }
4331
- }
4332
- newStartVnode = newCh[++newStartIdx];
4333
- }
4511
+ let oldStartIdx = 0;
4512
+ let newStartIdx = 0;
4513
+ let oldEndIdx = oldCh.length - 1;
4514
+ let oldStartVnode = oldCh[0];
4515
+ let oldEndVnode = oldCh[oldEndIdx];
4516
+ const newChEnd = newCh.length - 1;
4517
+ let newEndIdx = newChEnd;
4518
+ let newStartVnode = newCh[0];
4519
+ let newEndVnode = newCh[newEndIdx];
4520
+ let oldKeyToIdx;
4521
+ let idxInOld;
4522
+ let elmToMove;
4523
+ let before;
4524
+ let clonedOldCh = false;
4525
+
4526
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4527
+ if (!isVNode(oldStartVnode)) {
4528
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
4529
+ } else if (!isVNode(oldEndVnode)) {
4530
+ oldEndVnode = oldCh[--oldEndIdx];
4531
+ } else if (!isVNode(newStartVnode)) {
4532
+ newStartVnode = newCh[++newStartIdx];
4533
+ } else if (!isVNode(newEndVnode)) {
4534
+ newEndVnode = newCh[--newEndIdx];
4535
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4536
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4537
+ oldStartVnode = oldCh[++oldStartIdx];
4538
+ newStartVnode = newCh[++newStartIdx];
4539
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4540
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4541
+ oldEndVnode = oldCh[--oldEndIdx];
4542
+ newEndVnode = newCh[--newEndIdx];
4543
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4544
+ // Vnode moved right
4545
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4546
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4547
+ oldStartVnode = oldCh[++oldStartIdx];
4548
+ newEndVnode = newCh[--newEndIdx];
4549
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4550
+ // Vnode moved left
4551
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4552
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4553
+ oldEndVnode = oldCh[--oldEndIdx];
4554
+ newStartVnode = newCh[++newStartIdx];
4555
+ } else {
4556
+ if (oldKeyToIdx === undefined) {
4557
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4558
+ }
4559
+
4560
+ idxInOld = oldKeyToIdx[newStartVnode.key];
4561
+
4562
+ if (isUndefined$1(idxInOld)) {
4563
+ // New element
4564
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4565
+ newStartVnode = newCh[++newStartIdx];
4566
+ } else {
4567
+ elmToMove = oldCh[idxInOld];
4568
+
4569
+ if (isVNode(elmToMove)) {
4570
+ if (elmToMove.sel !== newStartVnode.sel) {
4571
+ // New element
4572
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4573
+ } else {
4574
+ patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
4575
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4576
+ // so we only care about the `oldCh` object inside this function.
4577
+ // To avoid cloning over and over again, we check `clonedOldCh`
4578
+ // and only clone once.
4579
+
4580
+ if (!clonedOldCh) {
4581
+ clonedOldCh = true;
4582
+ oldCh = [...oldCh];
4583
+ } // We've already cloned at least once, so it's no longer read-only
4584
+
4585
+
4586
+ oldCh[idxInOld] = undefined;
4587
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4588
+ }
4334
4589
  }
4590
+
4591
+ newStartVnode = newCh[++newStartIdx];
4592
+ }
4335
4593
  }
4336
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4337
- if (oldStartIdx > oldEndIdx) {
4338
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4339
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4340
- let i = newEndIdx;
4341
- let n;
4342
- do {
4343
- n = newCh[++i];
4344
- } while (!isVNode(n) && i < newChEnd);
4345
- before = isVNode(n) ? n.elm : null;
4346
- mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4347
- }
4348
- else {
4349
- unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4350
- }
4594
+ }
4595
+
4596
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4597
+ if (oldStartIdx > oldEndIdx) {
4598
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4599
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4600
+ let i = newEndIdx;
4601
+ let n;
4602
+
4603
+ do {
4604
+ n = newCh[++i];
4605
+ } while (!isVNode(n) && i < newChEnd);
4606
+
4607
+ before = isVNode(n) ? n.elm : null;
4608
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4609
+ } else {
4610
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4351
4611
  }
4612
+ }
4352
4613
  }
4614
+
4353
4615
  function updateStaticChildren(c1, c2, parent, renderer) {
4354
- const c1Length = c1.length;
4355
- const c2Length = c2.length;
4356
- if (c1Length === 0) {
4357
- // the old list is empty, we can directly insert anything new
4358
- mountVNodes(c2, parent, renderer, null);
4359
- return;
4360
- }
4361
- if (c2Length === 0) {
4362
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4363
- // this is the case in which the dynamic children of an if-directive should be removed
4364
- unmountVNodes(c1, parent, renderer, true);
4365
- return;
4366
- }
4367
- // if the old list is not empty, the new list MUST have the same
4368
- // amount of nodes, that's why we call this static children
4369
- let anchor = null;
4370
- for (let i = c2Length - 1; i >= 0; i -= 1) {
4371
- const n1 = c1[i];
4372
- const n2 = c2[i];
4373
- if (n2 !== n1) {
4374
- if (isVNode(n1)) {
4375
- if (isVNode(n2)) {
4376
- // both vnodes are equivalent, and we just need to patch them
4377
- patch(n1, n2, parent, renderer);
4378
- anchor = n2.elm;
4379
- }
4380
- else {
4381
- // removing the old vnode since the new one is null
4382
- unmount(n1, parent, renderer, true);
4383
- }
4384
- }
4385
- else if (isVNode(n2)) {
4386
- mount(n2, parent, renderer, anchor);
4387
- anchor = n2.elm;
4388
- }
4616
+ const c1Length = c1.length;
4617
+ const c2Length = c2.length;
4618
+
4619
+ if (c1Length === 0) {
4620
+ // the old list is empty, we can directly insert anything new
4621
+ mountVNodes(c2, parent, renderer, null);
4622
+ return;
4623
+ }
4624
+
4625
+ if (c2Length === 0) {
4626
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4627
+ // this is the case in which the dynamic children of an if-directive should be removed
4628
+ unmountVNodes(c1, parent, renderer, true);
4629
+ return;
4630
+ } // if the old list is not empty, the new list MUST have the same
4631
+ // amount of nodes, that's why we call this static children
4632
+
4633
+
4634
+ let anchor = null;
4635
+
4636
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4637
+ const n1 = c1[i];
4638
+ const n2 = c2[i];
4639
+
4640
+ if (n2 !== n1) {
4641
+ if (isVNode(n1)) {
4642
+ if (isVNode(n2)) {
4643
+ // both vnodes are equivalent, and we just need to patch them
4644
+ patch(n1, n2, parent, renderer);
4645
+ anchor = n2.elm;
4646
+ } else {
4647
+ // removing the old vnode since the new one is null
4648
+ unmount(n1, parent, renderer, true);
4389
4649
  }
4650
+ } else if (isVNode(n2)) {
4651
+ mount(n2, parent, renderer, anchor);
4652
+ anchor = n2.elm;
4653
+ }
4390
4654
  }
4655
+ }
4391
4656
  }
4392
4657
 
4393
4658
  /*
@@ -6342,6 +6607,7 @@ function hydrateNode(node, vnode, renderer) {
6342
6607
  }
6343
6608
  return renderer.nextSibling(hydratedNode);
6344
6609
  }
6610
+ const NODE_VALUE_PROP = 'nodeValue';
6345
6611
  function hydrateText(node, vnode, renderer) {
6346
6612
  var _a;
6347
6613
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -6349,7 +6615,7 @@ function hydrateText(node, vnode, renderer) {
6349
6615
  }
6350
6616
  if (process.env.NODE_ENV !== 'production') {
6351
6617
  const { getProperty } = renderer;
6352
- const nodeValue = getProperty(node, 'nodeValue');
6618
+ const nodeValue = getProperty(node, NODE_VALUE_PROP);
6353
6619
  if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
6354
6620
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6355
6621
  }
@@ -6366,13 +6632,13 @@ function hydrateComment(node, vnode, renderer) {
6366
6632
  }
6367
6633
  if (process.env.NODE_ENV !== 'production') {
6368
6634
  const { getProperty } = renderer;
6369
- const nodeValue = getProperty(node, 'nodeValue');
6635
+ const nodeValue = getProperty(node, NODE_VALUE_PROP);
6370
6636
  if (nodeValue !== vnode.text) {
6371
6637
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6372
6638
  }
6373
6639
  }
6374
6640
  const { setProperty } = renderer;
6375
- setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6641
+ setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6376
6642
  vnode.elm = node;
6377
6643
  return node;
6378
6644
  }
@@ -6640,13 +6906,13 @@ function areCompatibleNodes(client, ssr, vnode, renderer) {
6640
6906
  if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
6641
6907
  return false;
6642
6908
  }
6643
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6909
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
6644
6910
  }
6645
6911
  if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
6646
6912
  if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
6647
6913
  return false;
6648
6914
  }
6649
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6915
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
6650
6916
  }
6651
6917
  if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
6652
6918
  return false;
@@ -6802,7 +7068,7 @@ function getComponentConstructor(elm) {
6802
7068
  }
6803
7069
  return ctor;
6804
7070
  }
6805
- /* version: 2.23.1 */
7071
+ /* version: 2.23.2 */
6806
7072
 
6807
7073
  /*
6808
7074
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6952,61 +7218,303 @@ function insertStylesheet(content, target) {
6952
7218
  * SPDX-License-Identifier: MIT
6953
7219
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6954
7220
  */
6955
- const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
6956
- let createFragment;
6957
- if (SUPPORTS_TEMPLATE) {
6958
- // Parse the fragment HTML string into DOM
6959
- createFragment = function (html) {
6960
- const template = document.createElement('template');
6961
- template.innerHTML = html;
6962
- return template.content.firstChild;
6963
- };
6964
- }
6965
- else {
6966
- // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
6967
- // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
6968
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
6969
- // With other elements added from:
6970
- // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
6971
- // Using the test:
6972
- // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
6973
- // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
6974
- const topLevelWrappingMap = {
6975
- caption: ['table'],
6976
- col: ['colgroup', 'table'],
6977
- colgroup: ['table'],
6978
- option: ['select'],
6979
- tbody: ['table'],
6980
- td: ['tr', 'tbody', 'table'],
6981
- th: ['tr', 'tbody', 'table'],
6982
- thead: ['table'],
6983
- tfoot: ['table'],
6984
- tr: ['tbody', 'table'],
6985
- };
6986
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
6987
- const getTagName = function (text) {
6988
- return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
6989
- };
6990
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
6991
- createFragment = function (html) {
6992
- const wrapperTags = topLevelWrappingMap[getTagName(html)];
6993
- if (!isUndefined$1(wrapperTags)) {
6994
- for (const wrapperTag of wrapperTags) {
6995
- html = `<${wrapperTag}>${html}</${wrapperTag}>`;
7221
+ /**
7222
+ * A factory function that produces a renderer.
7223
+ * Renderer encapsulates operations that are required to render an LWC component into the underlying
7224
+ * runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
7225
+ * Example usage:
7226
+ * import { renderer, rendererFactory } from 'lwc';
7227
+ * const customRenderer = rendererFactory(renderer);
7228
+ *
7229
+ * @param baseRenderer Either null or the base renderer imported from 'lwc'.
7230
+ */
7231
+ function rendererFactory(baseRenderer) {
7232
+ // Util functions
7233
+ function assertInvariant(value, msg) {
7234
+ if (!value) {
7235
+ throw new Error(`Invariant Violation: ${msg}`);
7236
+ }
7237
+ }
7238
+ function isNull(obj) {
7239
+ return obj === null;
7240
+ }
7241
+ function isUndefined(obj) {
7242
+ return obj === undefined;
7243
+ }
7244
+ let getCustomElement;
7245
+ let defineCustomElement;
7246
+ let HTMLElementConstructor;
7247
+ function isCustomElementRegistryAvailable() {
7248
+ if (typeof customElements === 'undefined') {
7249
+ return false;
7250
+ }
7251
+ try {
7252
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
7253
+ // _wrapNativeSuper()
7254
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
7255
+ // get wrapped by babel.
7256
+ const HTMLElementAlias = HTMLElement;
7257
+ // In case we use compat mode with a modern browser, the compat mode transformation
7258
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
7259
+ // which are not equipped to be initialized that way.
7260
+ class clazz extends HTMLElementAlias {
6996
7261
  }
7262
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
7263
+ new clazz();
7264
+ return true;
7265
+ }
7266
+ catch (_a) {
7267
+ return false;
6997
7268
  }
6998
- // For IE11, the document title must not be undefined, but it can be an empty string
6999
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
7000
- const doc = document.implementation.createHTMLDocument('');
7001
- doc.body.innerHTML = html;
7002
- let content = doc.body;
7003
- if (!isUndefined$1(wrapperTags)) {
7004
- for (let i = 0; i < wrapperTags.length; i++) {
7005
- content = content.firstChild;
7269
+ }
7270
+ if (isCustomElementRegistryAvailable()) {
7271
+ getCustomElement = customElements.get.bind(customElements);
7272
+ defineCustomElement = customElements.define.bind(customElements);
7273
+ HTMLElementConstructor = HTMLElement;
7274
+ }
7275
+ else {
7276
+ const registry = Object.create(null);
7277
+ const reverseRegistry = new WeakMap();
7278
+ defineCustomElement = function define(name, ctor) {
7279
+ if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
7280
+ throw new TypeError(`Invalid Registration`);
7281
+ }
7282
+ registry[name] = ctor;
7283
+ reverseRegistry.set(ctor, name);
7284
+ };
7285
+ getCustomElement = function get(name) {
7286
+ return registry[name];
7287
+ };
7288
+ HTMLElementConstructor = function HTMLElement() {
7289
+ if (!(this instanceof HTMLElement)) {
7290
+ throw new TypeError(`Invalid Invocation`);
7291
+ }
7292
+ const { constructor } = this;
7293
+ const name = reverseRegistry.get(constructor);
7294
+ if (!name) {
7295
+ throw new TypeError(`Invalid Construction`);
7006
7296
  }
7297
+ const elm = document.createElement(name);
7298
+ Object.setPrototypeOf(elm, constructor.prototype);
7299
+ return elm;
7300
+ };
7301
+ HTMLElementConstructor.prototype = HTMLElement.prototype;
7302
+ }
7303
+ function cloneNode(node, deep) {
7304
+ return node.cloneNode(deep);
7305
+ }
7306
+ function createElement(tagName, namespace) {
7307
+ return isUndefined(namespace)
7308
+ ? document.createElement(tagName)
7309
+ : document.createElementNS(namespace, tagName);
7310
+ }
7311
+ function createText(content) {
7312
+ return document.createTextNode(content);
7313
+ }
7314
+ function createComment(content) {
7315
+ return document.createComment(content);
7316
+ }
7317
+ let createFragment;
7318
+ // IE11 lacks support for this feature
7319
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
7320
+ if (SUPPORTS_TEMPLATE) {
7321
+ // Parse the fragment HTML string into DOM
7322
+ createFragment = function (html) {
7323
+ const template = document.createElement('template');
7324
+ template.innerHTML = html;
7325
+ return template.content.firstChild;
7326
+ };
7327
+ }
7328
+ else {
7329
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
7330
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
7331
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
7332
+ // With other elements added from:
7333
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
7334
+ // Using the test:
7335
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
7336
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
7337
+ const topLevelWrappingMap = {
7338
+ caption: ['table'],
7339
+ col: ['colgroup', 'table'],
7340
+ colgroup: ['table'],
7341
+ option: ['select'],
7342
+ tbody: ['table'],
7343
+ td: ['tr', 'tbody', 'table'],
7344
+ th: ['tr', 'tbody', 'table'],
7345
+ thead: ['table'],
7346
+ tfoot: ['table'],
7347
+ tr: ['tbody', 'table'],
7348
+ };
7349
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
7350
+ const getTagName = function (text) {
7351
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
7352
+ };
7353
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
7354
+ createFragment = function (html) {
7355
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
7356
+ if (!isUndefined(wrapperTags)) {
7357
+ for (const wrapperTag of wrapperTags) {
7358
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
7359
+ }
7360
+ }
7361
+ // For IE11, the document title must not be undefined, but it can be an empty string
7362
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
7363
+ const doc = document.implementation.createHTMLDocument('');
7364
+ doc.body.innerHTML = html;
7365
+ let content = doc.body;
7366
+ if (!isUndefined(wrapperTags)) {
7367
+ for (let i = 0; i < wrapperTags.length; i++) {
7368
+ content = content.firstChild;
7369
+ }
7370
+ }
7371
+ return content.firstChild;
7372
+ };
7373
+ }
7374
+ function insert(node, parent, anchor) {
7375
+ parent.insertBefore(node, anchor);
7376
+ }
7377
+ function remove(node, parent) {
7378
+ parent.removeChild(node);
7379
+ }
7380
+ function nextSibling(node) {
7381
+ return node.nextSibling;
7382
+ }
7383
+ function attachShadow(element, options) {
7384
+ // `shadowRoot` will be non-null in two cases:
7385
+ // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7386
+ // 2. when a webapp author places <c-app> in their static HTML and mounts their
7387
+ // root component with customElement.define('c-app', Ctor)
7388
+ if (!isNull(element.shadowRoot)) {
7389
+ return element.shadowRoot;
7390
+ }
7391
+ return element.attachShadow(options);
7392
+ }
7393
+ function setText(node, content) {
7394
+ node.nodeValue = content;
7395
+ }
7396
+ function getProperty(node, key) {
7397
+ return node[key];
7398
+ }
7399
+ function setProperty(node, key, value) {
7400
+ node[key] = value;
7401
+ }
7402
+ function getAttribute(element, name, namespace) {
7403
+ return isUndefined(namespace)
7404
+ ? element.getAttribute(name)
7405
+ : element.getAttributeNS(namespace, name);
7406
+ }
7407
+ function setAttribute(element, name, value, namespace) {
7408
+ return isUndefined(namespace)
7409
+ ? element.setAttribute(name, value)
7410
+ : element.setAttributeNS(namespace, name, value);
7411
+ }
7412
+ function removeAttribute(element, name, namespace) {
7413
+ if (isUndefined(namespace)) {
7414
+ element.removeAttribute(name);
7007
7415
  }
7008
- return content.firstChild;
7416
+ else {
7417
+ element.removeAttributeNS(namespace, name);
7418
+ }
7419
+ }
7420
+ function addEventListener(target, type, callback, options) {
7421
+ target.addEventListener(type, callback, options);
7422
+ }
7423
+ function removeEventListener(target, type, callback, options) {
7424
+ target.removeEventListener(type, callback, options);
7425
+ }
7426
+ function dispatchEvent(target, event) {
7427
+ return target.dispatchEvent(event);
7428
+ }
7429
+ function getClassList(element) {
7430
+ return element.classList;
7431
+ }
7432
+ function setCSSStyleProperty(element, name, value, important) {
7433
+ // TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
7434
+ // represent elements in the engine?
7435
+ element.style.setProperty(name, value, important ? 'important' : '');
7436
+ }
7437
+ function getBoundingClientRect(element) {
7438
+ return element.getBoundingClientRect();
7439
+ }
7440
+ function querySelector(element, selectors) {
7441
+ return element.querySelector(selectors);
7442
+ }
7443
+ function querySelectorAll(element, selectors) {
7444
+ return element.querySelectorAll(selectors);
7445
+ }
7446
+ function getElementsByTagName(element, tagNameOrWildCard) {
7447
+ return element.getElementsByTagName(tagNameOrWildCard);
7448
+ }
7449
+ function getElementsByClassName(element, names) {
7450
+ return element.getElementsByClassName(names);
7451
+ }
7452
+ function getChildren(element) {
7453
+ return element.children;
7454
+ }
7455
+ function getChildNodes(element) {
7456
+ return element.childNodes;
7457
+ }
7458
+ function getFirstChild(element) {
7459
+ return element.firstChild;
7460
+ }
7461
+ function getFirstElementChild(element) {
7462
+ return element.firstElementChild;
7463
+ }
7464
+ function getLastChild(element) {
7465
+ return element.lastChild;
7466
+ }
7467
+ function getLastElementChild(element) {
7468
+ return element.lastElementChild;
7469
+ }
7470
+ function isConnected(node) {
7471
+ return node.isConnected;
7472
+ }
7473
+ function assertInstanceOfHTMLElement(elm, msg) {
7474
+ assertInvariant(elm instanceof HTMLElement, msg);
7475
+ }
7476
+ const HTMLElementExported = HTMLElementConstructor;
7477
+ const renderer = {
7478
+ HTMLElementExported,
7479
+ insert,
7480
+ remove,
7481
+ cloneNode,
7482
+ createFragment,
7483
+ createElement,
7484
+ createText,
7485
+ createComment,
7486
+ nextSibling,
7487
+ attachShadow,
7488
+ getProperty,
7489
+ setProperty,
7490
+ setText,
7491
+ getAttribute,
7492
+ setAttribute,
7493
+ removeAttribute,
7494
+ addEventListener,
7495
+ removeEventListener,
7496
+ dispatchEvent,
7497
+ getClassList,
7498
+ setCSSStyleProperty,
7499
+ getBoundingClientRect,
7500
+ querySelector,
7501
+ querySelectorAll,
7502
+ getElementsByTagName,
7503
+ getElementsByClassName,
7504
+ getChildren,
7505
+ getChildNodes,
7506
+ getFirstChild,
7507
+ getFirstElementChild,
7508
+ getLastChild,
7509
+ getLastElementChild,
7510
+ isConnected,
7511
+ assertInstanceOfHTMLElement,
7512
+ defineCustomElement,
7513
+ getCustomElement,
7009
7514
  };
7515
+ // Meant to inherit any properties passed via the base renderer as the argument to the factory.
7516
+ Object.setPrototypeOf(renderer, baseRenderer);
7517
+ return renderer;
7010
7518
  }
7011
7519
 
7012
7520
  /*
@@ -7015,231 +7523,21 @@ else {
7015
7523
  * SPDX-License-Identifier: MIT
7016
7524
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7017
7525
  */
7018
- let getCustomElement;
7019
- let defineCustomElement;
7020
- let HTMLElementConstructor;
7021
- function isCustomElementRegistryAvailable() {
7022
- if (typeof customElements === 'undefined') {
7023
- return false;
7024
- }
7025
- try {
7026
- // dereference HTMLElement global because babel wraps globals in compat mode with a
7027
- // _wrapNativeSuper()
7028
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
7029
- // get wrapped by babel.
7030
- const HTMLElementAlias = HTMLElement;
7031
- // In case we use compat mode with a modern browser, the compat mode transformation
7032
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
7033
- // which are not equipped to be initialized that way.
7034
- class clazz extends HTMLElementAlias {
7035
- }
7036
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
7037
- new clazz();
7038
- return true;
7039
- }
7040
- catch (_a) {
7041
- return false;
7042
- }
7043
- }
7044
- if (isCustomElementRegistryAvailable()) {
7045
- getCustomElement = customElements.get.bind(customElements);
7046
- defineCustomElement = customElements.define.bind(customElements);
7047
- HTMLElementConstructor = HTMLElement;
7048
- }
7049
- else {
7050
- const registry = create(null);
7051
- const reverseRegistry = new WeakMap();
7052
- defineCustomElement = function define(name, ctor) {
7053
- if (name !== StringToLowerCase.call(name) || registry[name]) {
7054
- throw new TypeError(`Invalid Registration`);
7055
- }
7056
- registry[name] = ctor;
7057
- reverseRegistry.set(ctor, name);
7058
- };
7059
- getCustomElement = function get(name) {
7060
- return registry[name];
7061
- };
7062
- HTMLElementConstructor = function HTMLElement() {
7063
- if (!(this instanceof HTMLElement)) {
7064
- throw new TypeError(`Invalid Invocation`);
7065
- }
7066
- const { constructor } = this;
7067
- const name = reverseRegistry.get(constructor);
7068
- if (!name) {
7069
- throw new TypeError(`Invalid Construction`);
7070
- }
7071
- const elm = document.createElement(name);
7072
- setPrototypeOf(elm, constructor.prototype);
7073
- return elm;
7074
- };
7075
- HTMLElementConstructor.prototype = HTMLElement.prototype;
7076
- }
7077
- const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7078
- const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7079
- function cloneNode(node, deep) {
7080
- return node.cloneNode(deep);
7081
- }
7082
- function createElement$1(tagName, namespace) {
7083
- return isUndefined$1(namespace)
7084
- ? document.createElement(tagName)
7085
- : document.createElementNS(namespace, tagName);
7086
- }
7087
- function createText(content) {
7088
- return document.createTextNode(content);
7089
- }
7090
- function createComment(content) {
7091
- return document.createComment(content);
7092
- }
7093
- function insert(node, parent, anchor) {
7094
- parent.insertBefore(node, anchor);
7095
- }
7096
- function remove(node, parent) {
7097
- parent.removeChild(node);
7098
- }
7099
- function nextSibling(node) {
7100
- return node.nextSibling;
7101
- }
7102
- function attachShadow(element, options) {
7103
- // `shadowRoot` will be non-null in two cases:
7104
- // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7105
- // 2. when a webapp author places <c-app> in their static HTML and mounts their
7106
- // root component with customElement.define('c-app', Ctor)
7107
- if (!isNull(element.shadowRoot)) {
7108
- return element.shadowRoot;
7109
- }
7110
- return element.attachShadow(options);
7111
- }
7112
- function setText(node, content) {
7113
- node.nodeValue = content;
7114
- }
7115
- function getProperty(node, key) {
7116
- return node[key];
7117
- }
7118
- function setProperty(node, key, value) {
7119
- if (process.env.NODE_ENV !== 'production') {
7120
- if (node instanceof Element && !(key in node)) {
7121
- // TODO [#1297]: Move this validation to the compiler
7122
- assert.fail(`Unknown public property "${key}" of element <${node.tagName}>. This is likely a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}".`);
7123
- }
7124
- }
7125
- node[key] = value;
7126
- }
7127
- function getAttribute(element, name, namespace) {
7128
- return isUndefined$1(namespace)
7129
- ? element.getAttribute(name)
7130
- : element.getAttributeNS(namespace, name);
7131
- }
7132
- function setAttribute(element, name, value, namespace) {
7133
- return isUndefined$1(namespace)
7134
- ? element.setAttribute(name, value)
7135
- : element.setAttributeNS(namespace, name, value);
7136
- }
7137
- function removeAttribute(element, name, namespace) {
7138
- if (isUndefined$1(namespace)) {
7139
- element.removeAttribute(name);
7140
- }
7141
- else {
7142
- element.removeAttributeNS(namespace, name);
7143
- }
7144
- }
7145
- function addEventListener(target, type, callback, options) {
7146
- target.addEventListener(type, callback, options);
7147
- }
7148
- function removeEventListener(target, type, callback, options) {
7149
- target.removeEventListener(type, callback, options);
7150
- }
7151
- function dispatchEvent(target, event) {
7152
- return target.dispatchEvent(event);
7153
- }
7154
- function getClassList(element) {
7155
- return element.classList;
7156
- }
7157
- function setCSSStyleProperty(element, name, value, important) {
7158
- // TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
7159
- // represent elements in the engine?
7160
- element.style.setProperty(name, value, important ? 'important' : '');
7161
- }
7162
- function getBoundingClientRect(element) {
7163
- return element.getBoundingClientRect();
7164
- }
7165
- function querySelector(element, selectors) {
7166
- return element.querySelector(selectors);
7167
- }
7168
- function querySelectorAll(element, selectors) {
7169
- return element.querySelectorAll(selectors);
7170
- }
7171
- function getElementsByTagName(element, tagNameOrWildCard) {
7172
- return element.getElementsByTagName(tagNameOrWildCard);
7173
- }
7174
- function getElementsByClassName(element, names) {
7175
- return element.getElementsByClassName(names);
7176
- }
7177
- function getChildren(element) {
7178
- return element.children;
7179
- }
7180
- function getChildNodes(element) {
7181
- return element.childNodes;
7182
- }
7183
- function getFirstChild(element) {
7184
- return element.firstChild;
7185
- }
7186
- function getFirstElementChild(element) {
7187
- return element.firstElementChild;
7188
- }
7189
- function getLastChild(element) {
7190
- return element.lastChild;
7191
- }
7192
- function getLastElementChild(element) {
7193
- return element.lastElementChild;
7194
- }
7195
- function isConnected(node) {
7196
- return node.isConnected;
7197
- }
7198
- function assertInstanceOfHTMLElement(elm, msg) {
7199
- assert.invariant(elm instanceof HTMLElement, msg);
7200
- }
7201
- const HTMLElementExported = HTMLElementConstructor;
7202
- const renderer = {
7203
- isNativeShadowDefined,
7204
- isSyntheticShadowDefined,
7205
- HTMLElementExported,
7206
- insert,
7207
- remove,
7208
- cloneNode,
7209
- createFragment,
7210
- createElement: createElement$1,
7211
- createText,
7212
- createComment,
7213
- nextSibling,
7214
- attachShadow,
7215
- getProperty,
7216
- setProperty,
7217
- setText,
7218
- getAttribute,
7219
- setAttribute,
7220
- removeAttribute,
7221
- addEventListener,
7222
- removeEventListener,
7223
- dispatchEvent,
7224
- getClassList,
7225
- setCSSStyleProperty,
7226
- getBoundingClientRect,
7227
- querySelector,
7228
- querySelectorAll,
7229
- getElementsByTagName,
7230
- getElementsByClassName,
7231
- getChildren,
7232
- getChildNodes,
7233
- getFirstChild,
7234
- getFirstElementChild,
7235
- getLastChild,
7236
- getLastElementChild,
7237
- isConnected,
7526
+ /**
7527
+ * The base renderer that will be used by engine-core.
7528
+ * This will be used for DOM operations when lwc is running in a browser environment.
7529
+ */
7530
+ const renderer = assign(
7531
+ // The base renderer will invoke the factory with null and assign additional properties that are
7532
+ // shared across renderers
7533
+ rendererFactory(null),
7534
+ // Properties that are either not required to be sandboxed or rely on a globally shared information
7535
+ {
7536
+ // insertStyleSheet implementation shares a global cache of stylesheet data
7238
7537
  insertStylesheet,
7239
- assertInstanceOfHTMLElement,
7240
- defineCustomElement,
7241
- getCustomElement,
7242
- };
7538
+ isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7539
+ isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7540
+ });
7243
7541
 
7244
7542
  /*
7245
7543
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7375,44 +7673,60 @@ function buildCustomElementConstructor(Ctor) {
7375
7673
  * SPDX-License-Identifier: MIT
7376
7674
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7377
7675
  */
7378
- // TODO [#2472]: Remove this workaround when appropriate.
7379
7676
  // eslint-disable-next-line @lwc/lwc-internal/no-global-node
7677
+
7380
7678
  const _Node$1 = Node;
7381
7679
  const ConnectingSlot = new WeakMap();
7382
7680
  const DisconnectingSlot = new WeakMap();
7681
+
7383
7682
  function callNodeSlot(node, slot) {
7384
- if (process.env.NODE_ENV !== 'production') {
7385
- assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
7386
- }
7387
- const fn = slot.get(node);
7388
- if (!isUndefined$1(fn)) {
7389
- fn(node);
7390
- }
7391
- return node; // for convenience
7683
+ if (process.env.NODE_ENV !== 'production') {
7684
+ assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
7685
+ }
7686
+
7687
+ const fn = slot.get(node);
7688
+
7689
+ if (!isUndefined$1(fn)) {
7690
+ fn(node);
7691
+ }
7692
+
7693
+ return node; // for convenience
7392
7694
  }
7393
- // Monkey patching Node methods to be able to detect the insertions and removal of root elements
7394
- // created via createElement.
7395
- const { appendChild, insertBefore, removeChild, replaceChild } = _Node$1.prototype;
7396
- assign(_Node$1.prototype, {
7695
+
7696
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
7697
+ // Monkey patching Node methods to be able to detect the insertions and removal of root elements
7698
+ // created via createElement.
7699
+ const {
7700
+ appendChild,
7701
+ insertBefore,
7702
+ removeChild,
7703
+ replaceChild
7704
+ } = _Node$1.prototype;
7705
+ assign(_Node$1.prototype, {
7397
7706
  appendChild(newChild) {
7398
- const appendedNode = appendChild.call(this, newChild);
7399
- return callNodeSlot(appendedNode, ConnectingSlot);
7707
+ const appendedNode = appendChild.call(this, newChild);
7708
+ return callNodeSlot(appendedNode, ConnectingSlot);
7400
7709
  },
7710
+
7401
7711
  insertBefore(newChild, referenceNode) {
7402
- const insertedNode = insertBefore.call(this, newChild, referenceNode);
7403
- return callNodeSlot(insertedNode, ConnectingSlot);
7712
+ const insertedNode = insertBefore.call(this, newChild, referenceNode);
7713
+ return callNodeSlot(insertedNode, ConnectingSlot);
7404
7714
  },
7715
+
7405
7716
  removeChild(oldChild) {
7406
- const removedNode = removeChild.call(this, oldChild);
7407
- return callNodeSlot(removedNode, DisconnectingSlot);
7717
+ const removedNode = removeChild.call(this, oldChild);
7718
+ return callNodeSlot(removedNode, DisconnectingSlot);
7408
7719
  },
7720
+
7409
7721
  replaceChild(newChild, oldChild) {
7410
- const replacedNode = replaceChild.call(this, newChild, oldChild);
7411
- callNodeSlot(replacedNode, DisconnectingSlot);
7412
- callNodeSlot(newChild, ConnectingSlot);
7413
- return replacedNode;
7414
- },
7415
- });
7722
+ const replacedNode = replaceChild.call(this, newChild, oldChild);
7723
+ callNodeSlot(replacedNode, DisconnectingSlot);
7724
+ callNodeSlot(newChild, ConnectingSlot);
7725
+ return replacedNode;
7726
+ }
7727
+
7728
+ });
7729
+ }
7416
7730
  /**
7417
7731
  * EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
7418
7732
  * difference that in the options, you can pass the `is` property set to a Constructor instead of
@@ -7424,38 +7738,50 @@ assign(_Node$1.prototype, {
7424
7738
  * const el = createElement('x-foo', { is: FooCtor });
7425
7739
  * ```
7426
7740
  */
7741
+
7742
+
7427
7743
  function createElement(sel, options) {
7428
- if (!isObject(options) || isNull(options)) {
7429
- throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
7430
- }
7431
- const Ctor = options.is;
7432
- if (!isFunction$1(Ctor)) {
7433
- throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
7434
- }
7435
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
7436
- let wasComponentUpgraded = false;
7437
- // the custom element from the registry is expecting an upgrade callback
7438
- /**
7439
- * Note: if the upgradable constructor does not expect, or throw when we new it
7440
- * with a callback as the first argument, we could implement a more advanced
7441
- * mechanism that only passes that argument if the constructor is known to be
7442
- * an upgradable custom element.
7443
- */
7444
- const element = new UpgradableConstructor((elm) => {
7445
- createVM(elm, Ctor, renderer, {
7446
- tagName: sel,
7447
- mode: options.mode !== 'closed' ? 'open' : 'closed',
7448
- owner: null,
7449
- });
7450
- ConnectingSlot.set(elm, connectRootElement);
7451
- DisconnectingSlot.set(elm, disconnectRootElement);
7452
- wasComponentUpgraded = true;
7744
+ if (!isObject(options) || isNull(options)) {
7745
+ throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
7746
+ }
7747
+
7748
+ const Ctor = options.is;
7749
+
7750
+ if (!isFunction$1(Ctor)) {
7751
+ throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
7752
+ }
7753
+
7754
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
7755
+ let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
7756
+
7757
+ /**
7758
+ * Note: if the upgradable constructor does not expect, or throw when we new it
7759
+ * with a callback as the first argument, we could implement a more advanced
7760
+ * mechanism that only passes that argument if the constructor is known to be
7761
+ * an upgradable custom element.
7762
+ */
7763
+
7764
+ const element = new UpgradableConstructor(elm => {
7765
+ createVM(elm, Ctor, renderer, {
7766
+ tagName: sel,
7767
+ mode: options.mode !== 'closed' ? 'open' : 'closed',
7768
+ owner: null
7453
7769
  });
7454
- if (!wasComponentUpgraded) {
7455
- /* eslint-disable-next-line no-console */
7456
- console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
7770
+
7771
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
7772
+ ConnectingSlot.set(elm, connectRootElement);
7773
+ DisconnectingSlot.set(elm, disconnectRootElement);
7457
7774
  }
7458
- return element;
7775
+
7776
+ wasComponentUpgraded = true;
7777
+ });
7778
+
7779
+ if (!wasComponentUpgraded) {
7780
+ /* eslint-disable-next-line no-console */
7781
+ console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
7782
+ }
7783
+
7784
+ return element;
7459
7785
  }
7460
7786
 
7461
7787
  /*
@@ -7489,7 +7815,7 @@ function isNodeShadowed(node) {
7489
7815
  }
7490
7816
  // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
7491
7817
  // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
7492
- return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
7818
+ return renderer.isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
7493
7819
  }
7494
7820
 
7495
7821
  /*
@@ -7526,6 +7852,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7526
7852
  });
7527
7853
  freeze(LightningElement);
7528
7854
  seal(LightningElement.prototype);
7529
- /* version: 2.23.1 */
7855
+ /* version: 2.23.2 */
7530
7856
 
7531
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7857
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };