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