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