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