lwc 2.23.0 → 2.23.3

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