@lwc/engine-core 2.22.0 → 2.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /* proxy-compat-disable */
2
- import { runtimeFlags } from '@lwc/features';
2
+ import { lwcRuntimeFlags } from '@lwc/features';
3
3
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
4
4
  import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
5
5
 
@@ -15,7 +15,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
15
15
  window.addEventListener('test-dummy-flag', () => {
16
16
  let hasFlag = false;
17
17
 
18
- if (runtimeFlags.DUMMY_TEST_FLAG) {
18
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
19
19
  hasFlag = true;
20
20
  }
21
21
 
@@ -793,6 +793,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
793
793
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
794
794
  }
795
795
 
796
+ function updateComponentValue(vm, key, newValue) {
797
+ const { cmpFields } = vm;
798
+ if (newValue !== cmpFields[key]) {
799
+ cmpFields[key] = newValue;
800
+ componentValueMutated(vm, key);
801
+ }
802
+ }
803
+
796
804
  /**
797
805
  * Copyright (C) 2017 salesforce.com, inc.
798
806
  */
@@ -1425,10 +1433,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1425
1433
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1426
1434
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1427
1435
  }
1428
- if (newValue !== vm.cmpProps[propName]) {
1429
- vm.cmpProps[propName] = newValue;
1430
- componentValueMutated(vm, propName);
1431
- }
1436
+ updateComponentValue(vm, propName, newValue);
1432
1437
  return set.call(vm.elm, newValue);
1433
1438
  },
1434
1439
  };
@@ -1723,10 +1728,7 @@ function createObservedFieldPropertyDescriptor(key) {
1723
1728
  },
1724
1729
  set(newValue) {
1725
1730
  const vm = getAssociatedVM(this);
1726
- if (newValue !== vm.cmpFields[key]) {
1727
- vm.cmpFields[key] = newValue;
1728
- componentValueMutated(vm, key);
1729
- }
1731
+ updateComponentValue(vm, key, newValue);
1730
1732
  },
1731
1733
  enumerable: true,
1732
1734
  configurable: true,
@@ -1870,7 +1872,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
1870
1872
  }
1871
1873
 
1872
1874
  if (set) {
1873
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
1875
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
1874
1876
  let ro = vm.oar[key];
1875
1877
 
1876
1878
  if (isUndefined$1(ro)) {
@@ -1928,10 +1930,7 @@ function internalTrackDecorator(key) {
1928
1930
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
1929
1931
  }
1930
1932
  const reactiveOrAnyValue = getReactiveProxy(newValue);
1931
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1932
- vm.cmpFields[key] = reactiveOrAnyValue;
1933
- componentValueMutated(vm, key);
1934
- }
1933
+ updateComponentValue(vm, key, reactiveOrAnyValue);
1935
1934
  },
1936
1935
  enumerable: true,
1937
1936
  configurable: true,
@@ -1970,10 +1969,7 @@ function internalWireFieldDecorator(key) {
1970
1969
  * letting the author to do the wrong thing, but it will keep our
1971
1970
  * system to be backward compatible.
1972
1971
  */
1973
- if (value !== vm.cmpFields[key]) {
1974
- vm.cmpFields[key] = value;
1975
- componentValueMutated(vm, key);
1976
- }
1972
+ updateComponentValue(vm, key, value);
1977
1973
  },
1978
1974
  enumerable: true,
1979
1975
  configurable: true,
@@ -2528,7 +2524,7 @@ function getTemplateOrSwappedTemplate(tpl) {
2528
2524
  throw new ReferenceError();
2529
2525
  }
2530
2526
 
2531
- if (runtimeFlags.ENABLE_HMR) {
2527
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2532
2528
  const visited = new Set();
2533
2529
 
2534
2530
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2545,7 +2541,7 @@ function getComponentOrSwappedComponent(Ctor) {
2545
2541
  throw new ReferenceError();
2546
2542
  }
2547
2543
 
2548
- if (runtimeFlags.ENABLE_HMR) {
2544
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2549
2545
  const visited = new Set();
2550
2546
 
2551
2547
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -2562,7 +2558,7 @@ function getStyleOrSwappedStyle(style) {
2562
2558
  throw new ReferenceError();
2563
2559
  }
2564
2560
 
2565
- if (runtimeFlags.ENABLE_HMR) {
2561
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2566
2562
  const visited = new Set();
2567
2563
 
2568
2564
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -2579,7 +2575,7 @@ function setActiveVM(vm) {
2579
2575
  throw new ReferenceError();
2580
2576
  }
2581
2577
 
2582
- if (runtimeFlags.ENABLE_HMR) {
2578
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2583
2579
  // tracking active component
2584
2580
  const Ctor = vm.def.ctor;
2585
2581
  let componentVMs = activeComponents.get(Ctor);
@@ -2636,7 +2632,7 @@ function removeActiveVM(vm) {
2636
2632
  throw new ReferenceError();
2637
2633
  }
2638
2634
 
2639
- if (runtimeFlags.ENABLE_HMR) {
2635
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2640
2636
  // tracking inactive component
2641
2637
  const Ctor = vm.def.ctor;
2642
2638
  let list = activeComponents.get(Ctor);
@@ -2683,7 +2679,7 @@ function swapTemplate(oldTpl, newTpl) {
2683
2679
  }
2684
2680
  }
2685
2681
 
2686
- if (!runtimeFlags.ENABLE_HMR) {
2682
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2687
2683
  throw new Error('HMR is not enabled');
2688
2684
  }
2689
2685
 
@@ -2699,7 +2695,7 @@ function swapComponent(oldComponent, newComponent) {
2699
2695
  }
2700
2696
  }
2701
2697
 
2702
- if (!runtimeFlags.ENABLE_HMR) {
2698
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2703
2699
  throw new Error('HMR is not enabled');
2704
2700
  }
2705
2701
 
@@ -2713,7 +2709,7 @@ function swapStyle(oldStyle, newStyle) {
2713
2709
  return rehydrateHotStyle(oldStyle);
2714
2710
  }
2715
2711
 
2716
- if (!runtimeFlags.ENABLE_HMR) {
2712
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2717
2713
  throw new Error('HMR is not enabled');
2718
2714
  }
2719
2715
 
@@ -3062,13 +3058,13 @@ function getNearestNativeShadowComponent(vm) {
3062
3058
  return owner;
3063
3059
  }
3064
3060
  function createStylesheet(vm, stylesheets) {
3065
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3061
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3066
3062
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3067
3063
  for (let i = 0; i < stylesheets.length; i++) {
3068
3064
  insertStylesheet(stylesheets[i]);
3069
3065
  }
3070
3066
  }
3071
- else if (ssr || vm.hydrated) {
3067
+ else if (!process.env.IS_BROWSER || vm.hydrated) {
3072
3068
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3073
3069
  // This works in the client, because the stylesheets are created, and cached in the VM
3074
3070
  // the first time the VM renders.
@@ -3093,30 +3089,67 @@ function createStylesheet(vm, stylesheets) {
3093
3089
  * SPDX-License-Identifier: MIT
3094
3090
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3095
3091
  */
3092
+
3093
+ function checkHasVM(elm) {
3094
+ const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
3095
+
3096
+ if (process.env.NODE_ENV !== 'production' && !hasVM) {
3097
+ // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
3098
+ // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
3099
+ 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.`);
3100
+ }
3101
+
3102
+ return hasVM;
3103
+ }
3104
+
3096
3105
  function getUpgradableConstructor(tagName, renderer) {
3097
- const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3098
- // Should never get a tag with upper case letter at this point, the compiler should
3099
- // produce only tags with lowercase letters
3100
- // But, for backwards compatibility, we will lower case the tagName
3101
- tagName = tagName.toLowerCase();
3102
- let CE = getCustomElement(tagName);
3103
- if (!isUndefined$1(CE)) {
3104
- return CE;
3106
+ const {
3107
+ getCustomElement,
3108
+ HTMLElementExported: RendererHTMLElement,
3109
+ defineCustomElement
3110
+ } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
3111
+ // produce only tags with lowercase letters
3112
+ // But, for backwards compatibility, we will lower case the tagName
3113
+
3114
+ tagName = tagName.toLowerCase();
3115
+ let CE = getCustomElement(tagName);
3116
+
3117
+ if (!isUndefined$1(CE)) {
3118
+ return CE;
3119
+ }
3120
+ /**
3121
+ * LWC Upgradable Element reference to an element that was created
3122
+ * via the scoped registry mechanism, and that is ready to be upgraded.
3123
+ */
3124
+
3125
+
3126
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3127
+ constructor(upgradeCallback) {
3128
+ super();
3129
+
3130
+ if (isFunction$1(upgradeCallback)) {
3131
+ upgradeCallback(this); // nothing to do with the result for now
3132
+ }
3105
3133
  }
3106
- /**
3107
- * LWC Upgradable Element reference to an element that was created
3108
- * via the scoped registry mechanism, and that is ready to be upgraded.
3109
- */
3110
- CE = class LWCUpgradableElement extends RendererHTMLElement {
3111
- constructor(upgradeCallback) {
3112
- super();
3113
- if (isFunction$1(upgradeCallback)) {
3114
- upgradeCallback(this); // nothing to do with the result for now
3115
- }
3116
- }
3134
+
3135
+ };
3136
+
3137
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3138
+ CE.prototype.connectedCallback = function () {
3139
+ if (checkHasVM(this)) {
3140
+ connectRootElement(this);
3141
+ }
3117
3142
  };
3118
- defineCustomElement(tagName, CE);
3119
- return CE;
3143
+
3144
+ CE.prototype.disconnectedCallback = function () {
3145
+ if (checkHasVM(this)) {
3146
+ disconnectRootElement(this);
3147
+ }
3148
+ };
3149
+ }
3150
+
3151
+ defineCustomElement(tagName, CE);
3152
+ return CE;
3120
3153
  }
3121
3154
 
3122
3155
  /*
@@ -3204,6 +3237,14 @@ function patchProps(oldVnode, vnode, renderer) {
3204
3237
  // different than the one previously set.
3205
3238
  if (isFirstPatch ||
3206
3239
  cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3240
+ // Additional verification if properties are supported by the element
3241
+ // Validation relies on html properties and public properties being defined on the element,
3242
+ // SSR has its own custom validation.
3243
+ if (process.env.IS_BROWSER && process.env.NODE_ENV !== 'production') {
3244
+ if (!(key in elm)) {
3245
+ 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.`);
3246
+ }
3247
+ }
3207
3248
  setProperty(elm, key, cur);
3208
3249
  }
3209
3250
  }
@@ -3362,569 +3403,802 @@ function applyStaticStyleAttribute(vnode, renderer) {
3362
3403
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3363
3404
  */
3364
3405
  function patchChildren(c1, c2, parent, renderer) {
3365
- if (hasDynamicChildren(c2)) {
3366
- updateDynamicChildren(c1, c2, parent, renderer);
3367
- }
3368
- else {
3369
- updateStaticChildren(c1, c2, parent, renderer);
3370
- }
3406
+ if (hasDynamicChildren(c2)) {
3407
+ updateDynamicChildren(c1, c2, parent, renderer);
3408
+ } else {
3409
+ updateStaticChildren(c1, c2, parent, renderer);
3410
+ }
3371
3411
  }
3372
- function patch(n1, n2, renderer) {
3373
- var _a, _b;
3374
- if (n1 === n2) {
3375
- return;
3376
- }
3377
- if (process.env.NODE_ENV !== 'production') {
3378
- if (!isSameVnode(n1, n2)) {
3379
- throw new Error('Expected these VNodes to be the same: ' +
3380
- JSON.stringify({ sel: n1.sel, key: n1.key }) +
3381
- ', ' +
3382
- JSON.stringify({ sel: n2.sel, key: n2.key }));
3383
- }
3384
- }
3385
- switch (n2.type) {
3386
- case 0 /* VNodeType.Text */:
3387
- // VText has no special capability, fallback to the owner's renderer
3388
- patchText(n1, n2, renderer);
3389
- break;
3390
- case 1 /* VNodeType.Comment */:
3391
- // VComment has no special capability, fallback to the owner's renderer
3392
- patchComment(n1, n2, renderer);
3393
- break;
3394
- case 4 /* VNodeType.Static */:
3395
- n2.elm = n1.elm;
3396
- break;
3397
- case 2 /* VNodeType.Element */:
3398
- patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3399
- break;
3400
- case 3 /* VNodeType.CustomElement */:
3401
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3402
- break;
3412
+
3413
+ function patch(n1, n2, parent, renderer) {
3414
+ var _a, _b;
3415
+
3416
+ if (n1 === n2) {
3417
+ return;
3418
+ }
3419
+
3420
+ if (process.env.NODE_ENV !== 'production') {
3421
+ if (!isSameVnode(n1, n2)) {
3422
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
3423
+ sel: n1.sel,
3424
+ key: n1.key
3425
+ }) + ', ' + JSON.stringify({
3426
+ sel: n2.sel,
3427
+ key: n2.key
3428
+ }));
3403
3429
  }
3430
+ }
3431
+
3432
+ switch (n2.type) {
3433
+ case 0
3434
+ /* VNodeType.Text */
3435
+ :
3436
+ // VText has no special capability, fallback to the owner's renderer
3437
+ patchText(n1, n2, renderer);
3438
+ break;
3439
+
3440
+ case 1
3441
+ /* VNodeType.Comment */
3442
+ :
3443
+ // VComment has no special capability, fallback to the owner's renderer
3444
+ patchComment(n1, n2, renderer);
3445
+ break;
3446
+
3447
+ case 4
3448
+ /* VNodeType.Static */
3449
+ :
3450
+ n2.elm = n1.elm;
3451
+ break;
3452
+
3453
+ case 2
3454
+ /* VNodeType.Element */
3455
+ :
3456
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3457
+ break;
3458
+
3459
+ case 3
3460
+ /* VNodeType.CustomElement */
3461
+ :
3462
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3463
+ break;
3464
+ }
3404
3465
  }
3466
+
3405
3467
  function mount(node, parent, renderer, anchor) {
3406
- var _a, _b;
3407
- switch (node.type) {
3408
- case 0 /* VNodeType.Text */:
3409
- // VText has no special capability, fallback to the owner's renderer
3410
- mountText(node, parent, anchor, renderer);
3411
- break;
3412
- case 1 /* VNodeType.Comment */:
3413
- // VComment has no special capability, fallback to the owner's renderer
3414
- mountComment(node, parent, anchor, renderer);
3415
- break;
3416
- case 4 /* VNodeType.Static */:
3417
- // VStatic cannot have a custom renderer associated to them, using owner's renderer
3418
- mountStatic(node, parent, anchor, renderer);
3419
- break;
3420
- case 2 /* VNodeType.Element */:
3421
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3422
- mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3423
- break;
3424
- case 3 /* VNodeType.CustomElement */:
3425
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3426
- mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3427
- break;
3428
- }
3468
+ var _a, _b;
3469
+
3470
+ switch (node.type) {
3471
+ case 0
3472
+ /* VNodeType.Text */
3473
+ :
3474
+ // VText has no special capability, fallback to the owner's renderer
3475
+ mountText(node, parent, anchor, renderer);
3476
+ break;
3477
+
3478
+ case 1
3479
+ /* VNodeType.Comment */
3480
+ :
3481
+ // VComment has no special capability, fallback to the owner's renderer
3482
+ mountComment(node, parent, anchor, renderer);
3483
+ break;
3484
+
3485
+ case 4
3486
+ /* VNodeType.Static */
3487
+ :
3488
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3489
+ mountStatic(node, parent, anchor, renderer);
3490
+ break;
3491
+
3492
+ case 2
3493
+ /* VNodeType.Element */
3494
+ :
3495
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3496
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3497
+ break;
3498
+
3499
+ case 3
3500
+ /* VNodeType.CustomElement */
3501
+ :
3502
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3503
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3504
+ break;
3505
+ }
3429
3506
  }
3507
+
3430
3508
  function patchText(n1, n2, renderer) {
3431
- n2.elm = n1.elm;
3432
- if (n2.text !== n1.text) {
3433
- updateTextContent(n2, renderer);
3434
- }
3509
+ n2.elm = n1.elm;
3510
+
3511
+ if (n2.text !== n1.text) {
3512
+ updateTextContent(n2, renderer);
3513
+ }
3435
3514
  }
3515
+
3436
3516
  function mountText(vnode, parent, anchor, renderer) {
3437
- const { owner } = vnode;
3438
- const { createText } = renderer;
3439
- const textNode = (vnode.elm = createText(vnode.text));
3440
- linkNodeToShadow(textNode, owner, renderer);
3441
- insertNode(textNode, parent, anchor, renderer);
3517
+ const {
3518
+ owner
3519
+ } = vnode;
3520
+ const {
3521
+ createText
3522
+ } = renderer;
3523
+ const textNode = vnode.elm = createText(vnode.text);
3524
+ linkNodeToShadow(textNode, owner, renderer);
3525
+ insertNode(textNode, parent, anchor, renderer);
3442
3526
  }
3527
+
3443
3528
  function patchComment(n1, n2, renderer) {
3444
- n2.elm = n1.elm;
3445
- // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3446
- // it is the case today.
3447
- if (n2.text !== n1.text) {
3448
- updateTextContent(n2, renderer);
3449
- }
3529
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3530
+ // it is the case today.
3531
+
3532
+ if (n2.text !== n1.text) {
3533
+ updateTextContent(n2, renderer);
3534
+ }
3450
3535
  }
3536
+
3451
3537
  function mountComment(vnode, parent, anchor, renderer) {
3452
- const { owner } = vnode;
3453
- const { createComment } = renderer;
3454
- const commentNode = (vnode.elm = createComment(vnode.text));
3455
- linkNodeToShadow(commentNode, owner, renderer);
3456
- insertNode(commentNode, parent, anchor, renderer);
3538
+ const {
3539
+ owner
3540
+ } = vnode;
3541
+ const {
3542
+ createComment
3543
+ } = renderer;
3544
+ const commentNode = vnode.elm = createComment(vnode.text);
3545
+ linkNodeToShadow(commentNode, owner, renderer);
3546
+ insertNode(commentNode, parent, anchor, renderer);
3457
3547
  }
3548
+
3458
3549
  function mountElement(vnode, parent, anchor, renderer) {
3459
- const { sel, owner, data: { svg }, } = vnode;
3460
- const { createElement } = renderer;
3461
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3462
- const elm = (vnode.elm = createElement(sel, namespace));
3463
- linkNodeToShadow(elm, owner, renderer);
3464
- applyStyleScoping(elm, owner, renderer);
3465
- applyDomManual(elm, vnode);
3466
- applyElementRestrictions(elm, vnode);
3467
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3468
- insertNode(elm, parent, anchor, renderer);
3469
- mountVNodes(vnode.children, elm, renderer, null);
3550
+ const {
3551
+ sel,
3552
+ owner,
3553
+ data: {
3554
+ svg
3555
+ }
3556
+ } = vnode;
3557
+ const {
3558
+ createElement
3559
+ } = renderer;
3560
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3561
+ const elm = vnode.elm = createElement(sel, namespace);
3562
+ linkNodeToShadow(elm, owner, renderer);
3563
+ applyStyleScoping(elm, owner, renderer);
3564
+ applyDomManual(elm, vnode);
3565
+ applyElementRestrictions(elm, vnode);
3566
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3567
+ insertNode(elm, parent, anchor, renderer);
3568
+ mountVNodes(vnode.children, elm, renderer, null);
3470
3569
  }
3570
+
3471
3571
  function patchElement(n1, n2, renderer) {
3472
- const elm = (n2.elm = n1.elm);
3473
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3474
- patchChildren(n1.children, n2.children, elm, renderer);
3572
+ const elm = n2.elm = n1.elm;
3573
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3574
+ patchChildren(n1.children, n2.children, elm, renderer);
3475
3575
  }
3576
+
3476
3577
  function mountStatic(vnode, parent, anchor, renderer) {
3477
- const { owner } = vnode;
3478
- const { cloneNode, isSyntheticShadowDefined } = renderer;
3479
- const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3480
- linkNodeToShadow(elm, owner, renderer);
3481
- applyElementRestrictions(elm, vnode);
3482
- // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3483
- const { renderMode, shadowMode } = owner;
3484
- if (isSyntheticShadowDefined) {
3485
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3486
- elm[KEY__SHADOW_STATIC] = true;
3487
- }
3578
+ const {
3579
+ owner
3580
+ } = vnode;
3581
+ const {
3582
+ cloneNode,
3583
+ isSyntheticShadowDefined
3584
+ } = renderer;
3585
+ const elm = vnode.elm = cloneNode(vnode.fragment, true);
3586
+ linkNodeToShadow(elm, owner, renderer);
3587
+ applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3588
+
3589
+ const {
3590
+ renderMode,
3591
+ shadowMode
3592
+ } = owner;
3593
+
3594
+ if (isSyntheticShadowDefined) {
3595
+ if (shadowMode === 1
3596
+ /* ShadowMode.Synthetic */
3597
+ || renderMode === 0
3598
+ /* RenderMode.Light */
3599
+ ) {
3600
+ elm[KEY__SHADOW_STATIC] = true;
3488
3601
  }
3489
- insertNode(elm, parent, anchor, renderer);
3602
+ }
3603
+
3604
+ insertNode(elm, parent, anchor, renderer);
3490
3605
  }
3606
+
3491
3607
  function mountCustomElement(vnode, parent, anchor, renderer) {
3492
- const { sel, owner } = vnode;
3493
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3494
- /**
3495
- * Note: if the upgradable constructor does not expect, or throw when we new it
3496
- * with a callback as the first argument, we could implement a more advanced
3497
- * mechanism that only passes that argument if the constructor is known to be
3498
- * an upgradable custom element.
3499
- */
3500
- let vm;
3501
- const elm = new UpgradableConstructor((elm) => {
3502
- // the custom element from the registry is expecting an upgrade callback
3503
- vm = createViewModelHook(elm, vnode, renderer);
3504
- });
3505
- vnode.elm = elm;
3506
- vnode.vm = vm;
3507
- linkNodeToShadow(elm, owner, renderer);
3508
- applyStyleScoping(elm, owner, renderer);
3509
- if (vm) {
3510
- allocateChildren(vnode, vm);
3511
- }
3512
- else if (vnode.ctor !== UpgradableConstructor) {
3513
- throw new TypeError(`Incorrect Component Constructor`);
3514
- }
3515
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3516
- insertNode(elm, parent, anchor, renderer);
3517
- if (vm) {
3608
+ const {
3609
+ sel,
3610
+ owner
3611
+ } = vnode;
3612
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3613
+ /**
3614
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3615
+ * with a callback as the first argument, we could implement a more advanced
3616
+ * mechanism that only passes that argument if the constructor is known to be
3617
+ * an upgradable custom element.
3618
+ */
3619
+
3620
+ let vm;
3621
+ const elm = new UpgradableConstructor(elm => {
3622
+ // the custom element from the registry is expecting an upgrade callback
3623
+ vm = createViewModelHook(elm, vnode, renderer);
3624
+ });
3625
+ vnode.elm = elm;
3626
+ vnode.vm = vm;
3627
+ linkNodeToShadow(elm, owner, renderer);
3628
+ applyStyleScoping(elm, owner, renderer);
3629
+
3630
+ if (vm) {
3631
+ allocateChildren(vnode, vm);
3632
+ } else if (vnode.ctor !== UpgradableConstructor) {
3633
+ throw new TypeError(`Incorrect Component Constructor`);
3634
+ }
3635
+
3636
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3637
+ insertNode(elm, parent, anchor, renderer);
3638
+
3639
+ if (vm) {
3640
+ if (process.env.IS_BROWSER) {
3641
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3518
3642
  if (process.env.NODE_ENV !== 'production') {
3519
- assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
3643
+ // With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
3644
+ // noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
3645
+ assert.isTrue(vm.state === 0
3646
+ /* VMState.created */
3647
+ , `${vm} cannot be recycled.`);
3520
3648
  }
3649
+
3521
3650
  runConnectedCallback(vm);
3651
+ }
3652
+ } else {
3653
+ // On the server, we don't have native custom element lifecycle callbacks, so we must
3654
+ // manually invoke the connectedCallback for a child component.
3655
+ runConnectedCallback(vm);
3522
3656
  }
3523
- mountVNodes(vnode.children, elm, renderer, null);
3524
- if (vm) {
3525
- appendVM(vm);
3526
- }
3657
+ }
3658
+
3659
+ mountVNodes(vnode.children, elm, renderer, null);
3660
+
3661
+ if (vm) {
3662
+ appendVM(vm);
3663
+ }
3527
3664
  }
3528
- function patchCustomElement(n1, n2, renderer) {
3529
- const elm = (n2.elm = n1.elm);
3530
- const vm = (n2.vm = n1.vm);
3665
+
3666
+ function patchCustomElement(n1, n2, parent, renderer) {
3667
+ if (n1.ctor !== n2.ctor) {
3668
+ // If the constructor, unmount the current component and mount a new one using the new
3669
+ // constructor.
3670
+ const anchor = renderer.nextSibling(n1.elm);
3671
+ unmount(n1, parent, renderer, true);
3672
+ mountCustomElement(n2, parent, anchor, renderer);
3673
+ } else {
3674
+ // Otherwise patch the existing component with new props/attrs/etc.
3675
+ const elm = n2.elm = n1.elm;
3676
+ const vm = n2.vm = n1.vm;
3531
3677
  patchElementPropsAndAttrs$1(n1, n2, renderer);
3678
+
3532
3679
  if (!isUndefined$1(vm)) {
3533
- // in fallback mode, the allocation will always set children to
3534
- // empty and delegate the real allocation to the slot elements
3535
- allocateChildren(n2, vm);
3536
- }
3537
- // in fallback mode, the children will be always empty, so, nothing
3680
+ // in fallback mode, the allocation will always set children to
3681
+ // empty and delegate the real allocation to the slot elements
3682
+ allocateChildren(n2, vm);
3683
+ } // in fallback mode, the children will be always empty, so, nothing
3538
3684
  // will happen, but in native, it does allocate the light dom
3685
+
3686
+
3539
3687
  patchChildren(n1.children, n2.children, elm, renderer);
3688
+
3540
3689
  if (!isUndefined$1(vm)) {
3541
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3542
- // this is important to preserve the top to bottom synchronous rendering phase.
3543
- rerenderVM(vm);
3690
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3691
+ // this is important to preserve the top to bottom synchronous rendering phase.
3692
+ rerenderVM(vm);
3544
3693
  }
3694
+ }
3545
3695
  }
3696
+
3546
3697
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3547
- for (; start < end; ++start) {
3548
- const vnode = vnodes[start];
3549
- if (isVNode(vnode)) {
3550
- mount(vnode, parent, renderer, anchor);
3551
- }
3698
+ for (; start < end; ++start) {
3699
+ const vnode = vnodes[start];
3700
+
3701
+ if (isVNode(vnode)) {
3702
+ mount(vnode, parent, renderer, anchor);
3552
3703
  }
3704
+ }
3553
3705
  }
3706
+
3554
3707
  function unmount(vnode, parent, renderer, doRemove = false) {
3555
- const { type, elm, sel } = vnode;
3556
- // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3557
- // subtree root, is the only element worth unmounting from the subtree.
3558
- if (doRemove) {
3559
- // The vnode might or might not have a data.renderer associated to it
3560
- // but the removal used here is from the owner instead.
3561
- removeNode(elm, parent, renderer);
3562
- }
3563
- switch (type) {
3564
- case 2 /* VNodeType.Element */: {
3565
- // Slot content is removed to trigger slotchange event when removing slot.
3566
- // Only required for synthetic shadow.
3567
- const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
3568
- unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3569
- break;
3570
- }
3571
- case 3 /* VNodeType.CustomElement */: {
3572
- const { vm } = vnode;
3573
- // No need to unmount the children here, `removeVM` will take care of removing the
3574
- // children.
3575
- if (!isUndefined$1(vm)) {
3576
- removeVM(vm);
3577
- }
3708
+ const {
3709
+ type,
3710
+ elm,
3711
+ sel
3712
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3713
+ // subtree root, is the only element worth unmounting from the subtree.
3714
+
3715
+ if (doRemove) {
3716
+ // The vnode might or might not have a data.renderer associated to it
3717
+ // but the removal used here is from the owner instead.
3718
+ removeNode(elm, parent, renderer);
3719
+ }
3720
+
3721
+ switch (type) {
3722
+ case 2
3723
+ /* VNodeType.Element */
3724
+ :
3725
+ {
3726
+ // Slot content is removed to trigger slotchange event when removing slot.
3727
+ // Only required for synthetic shadow.
3728
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
3729
+ /* ShadowMode.Synthetic */
3730
+ ;
3731
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3732
+ break;
3733
+ }
3734
+
3735
+ case 3
3736
+ /* VNodeType.CustomElement */
3737
+ :
3738
+ {
3739
+ const {
3740
+ vm
3741
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
3742
+ // children.
3743
+
3744
+ if (!isUndefined$1(vm)) {
3745
+ removeVM(vm);
3578
3746
  }
3579
- }
3747
+ }
3748
+ }
3580
3749
  }
3750
+
3581
3751
  function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3582
- for (; start < end; ++start) {
3583
- const ch = vnodes[start];
3584
- if (isVNode(ch)) {
3585
- unmount(ch, parent, renderer, doRemove);
3586
- }
3752
+ for (; start < end; ++start) {
3753
+ const ch = vnodes[start];
3754
+
3755
+ if (isVNode(ch)) {
3756
+ unmount(ch, parent, renderer, doRemove);
3587
3757
  }
3758
+ }
3588
3759
  }
3760
+
3589
3761
  function isVNode(vnode) {
3590
- return vnode != null;
3762
+ return vnode != null;
3591
3763
  }
3764
+
3592
3765
  function linkNodeToShadow(elm, owner, renderer) {
3593
- const { renderRoot, renderMode, shadowMode } = owner;
3594
- const { isSyntheticShadowDefined } = renderer;
3595
- // TODO [#1164]: this should eventually be done by the polyfill directly
3596
- if (isSyntheticShadowDefined) {
3597
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3598
- elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3599
- }
3766
+ const {
3767
+ renderRoot,
3768
+ renderMode,
3769
+ shadowMode
3770
+ } = owner;
3771
+ const {
3772
+ isSyntheticShadowDefined
3773
+ } = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
3774
+
3775
+ if (isSyntheticShadowDefined) {
3776
+ if (shadowMode === 1
3777
+ /* ShadowMode.Synthetic */
3778
+ || renderMode === 0
3779
+ /* RenderMode.Light */
3780
+ ) {
3781
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3600
3782
  }
3783
+ }
3601
3784
  }
3785
+
3602
3786
  function updateTextContent(vnode, renderer) {
3603
- const { elm, text } = vnode;
3604
- const { setText } = renderer;
3605
- if (process.env.NODE_ENV !== 'production') {
3606
- unlockDomMutation();
3607
- }
3608
- setText(elm, text);
3609
- if (process.env.NODE_ENV !== 'production') {
3610
- lockDomMutation();
3611
- }
3787
+ const {
3788
+ elm,
3789
+ text
3790
+ } = vnode;
3791
+ const {
3792
+ setText
3793
+ } = renderer;
3794
+
3795
+ if (process.env.NODE_ENV !== 'production') {
3796
+ unlockDomMutation();
3797
+ }
3798
+
3799
+ setText(elm, text);
3800
+
3801
+ if (process.env.NODE_ENV !== 'production') {
3802
+ lockDomMutation();
3803
+ }
3612
3804
  }
3805
+
3613
3806
  function insertNode(node, parent, anchor, renderer) {
3614
- if (process.env.NODE_ENV !== 'production') {
3615
- unlockDomMutation();
3616
- }
3617
- renderer.insert(node, parent, anchor);
3618
- if (process.env.NODE_ENV !== 'production') {
3619
- lockDomMutation();
3620
- }
3807
+ if (process.env.NODE_ENV !== 'production') {
3808
+ unlockDomMutation();
3809
+ }
3810
+
3811
+ renderer.insert(node, parent, anchor);
3812
+
3813
+ if (process.env.NODE_ENV !== 'production') {
3814
+ lockDomMutation();
3815
+ }
3621
3816
  }
3817
+
3622
3818
  function removeNode(node, parent, renderer) {
3623
- if (process.env.NODE_ENV !== 'production') {
3624
- unlockDomMutation();
3625
- }
3626
- renderer.remove(node, parent);
3627
- if (process.env.NODE_ENV !== 'production') {
3628
- lockDomMutation();
3629
- }
3819
+ if (process.env.NODE_ENV !== 'production') {
3820
+ unlockDomMutation();
3821
+ }
3822
+
3823
+ renderer.remove(node, parent);
3824
+
3825
+ if (process.env.NODE_ENV !== 'production') {
3826
+ lockDomMutation();
3827
+ }
3630
3828
  }
3829
+
3631
3830
  function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3632
- if (isNull(oldVnode)) {
3633
- applyEventListeners(vnode, renderer);
3634
- applyStaticClassAttribute(vnode, renderer);
3635
- applyStaticStyleAttribute(vnode, renderer);
3636
- }
3637
- // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3638
- // value is set before type=radio.
3639
- patchClassAttribute(oldVnode, vnode, renderer);
3640
- patchStyleAttribute(oldVnode, vnode, renderer);
3641
- patchAttributes(oldVnode, vnode, renderer);
3642
- patchProps(oldVnode, vnode, renderer);
3831
+ if (isNull(oldVnode)) {
3832
+ applyEventListeners(vnode, renderer);
3833
+ applyStaticClassAttribute(vnode, renderer);
3834
+ applyStaticStyleAttribute(vnode, renderer);
3835
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3836
+ // value is set before type=radio.
3837
+
3838
+
3839
+ patchClassAttribute(oldVnode, vnode, renderer);
3840
+ patchStyleAttribute(oldVnode, vnode, renderer);
3841
+ patchAttributes(oldVnode, vnode, renderer);
3842
+ patchProps(oldVnode, vnode, renderer);
3643
3843
  }
3844
+
3644
3845
  function applyStyleScoping(elm, owner, renderer) {
3645
- // Set the class name for `*.scoped.css` style scoping.
3646
- const scopeToken = getScopeTokenClass(owner);
3647
- if (!isNull(scopeToken)) {
3648
- const { getClassList } = renderer;
3649
- // TODO [#2762]: this dot notation with add is probably problematic
3650
- // probably we should have a renderer api for just the add operation
3651
- getClassList(elm).add(scopeToken);
3652
- }
3653
- // Set property element for synthetic shadow DOM style scoping.
3654
- const { stylesheetToken: syntheticToken } = owner.context;
3655
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3656
- elm.$shadowToken$ = syntheticToken;
3657
- }
3846
+ // Set the class name for `*.scoped.css` style scoping.
3847
+ const scopeToken = getScopeTokenClass(owner);
3848
+
3849
+ if (!isNull(scopeToken)) {
3850
+ const {
3851
+ getClassList
3852
+ } = renderer; // TODO [#2762]: this dot notation with add is probably problematic
3853
+ // probably we should have a renderer api for just the add operation
3854
+
3855
+ getClassList(elm).add(scopeToken);
3856
+ } // Set property element for synthetic shadow DOM style scoping.
3857
+
3858
+
3859
+ const {
3860
+ stylesheetToken: syntheticToken
3861
+ } = owner.context;
3862
+
3863
+ if (owner.shadowMode === 1
3864
+ /* ShadowMode.Synthetic */
3865
+ && !isUndefined$1(syntheticToken)) {
3866
+ elm.$shadowToken$ = syntheticToken;
3867
+ }
3658
3868
  }
3869
+
3659
3870
  function applyDomManual(elm, vnode) {
3660
- var _a;
3661
- const { owner, data: { context }, } = vnode;
3662
- 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 */) {
3663
- elm.$domManual$ = true;
3871
+ var _a;
3872
+
3873
+ const {
3874
+ owner,
3875
+ data: {
3876
+ context
3664
3877
  }
3878
+ } = vnode;
3879
+
3880
+ if (owner.shadowMode === 1
3881
+ /* ShadowMode.Synthetic */
3882
+ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
3883
+ /* LwcDomMode.Manual */
3884
+ ) {
3885
+ elm.$domManual$ = true;
3886
+ }
3665
3887
  }
3888
+
3666
3889
  function applyElementRestrictions(elm, vnode) {
3667
- var _a, _b;
3668
- if (process.env.NODE_ENV !== 'production') {
3669
- 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 */;
3670
- const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
3671
- patchElementWithRestrictions(elm, {
3672
- isPortal,
3673
- isLight,
3674
- });
3675
- }
3890
+ var _a, _b;
3891
+
3892
+ if (process.env.NODE_ENV !== 'production') {
3893
+ const isPortal = vnode.type === 2
3894
+ /* VNodeType.Element */
3895
+ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
3896
+ /* LwcDomMode.Manual */
3897
+ ;
3898
+ const isLight = vnode.owner.renderMode === 0
3899
+ /* RenderMode.Light */
3900
+ ;
3901
+ patchElementWithRestrictions(elm, {
3902
+ isPortal,
3903
+ isLight
3904
+ });
3905
+ }
3676
3906
  }
3907
+
3677
3908
  function allocateChildren(vnode, vm) {
3678
- // A component with slots will re-render because:
3679
- // 1- There is a change of the internal state.
3680
- // 2- There is a change on the external api (ex: slots)
3681
- //
3682
- // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
3683
- // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
3684
- // in a reused VCustomElement, there won't be any slotted children.
3685
- // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
3686
- //
3687
- // In case #2, we will always get a fresh VCustomElement.
3688
- const children = vnode.aChildren || vnode.children;
3689
- vm.aChildren = children;
3690
- const { renderMode, shadowMode } = vm;
3691
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3692
- // slow path
3693
- allocateInSlot(vm, children);
3694
- // save the allocated children in case this vnode is reused.
3695
- vnode.aChildren = children;
3696
- // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3697
- vnode.children = EmptyArray;
3698
- }
3909
+ // A component with slots will re-render because:
3910
+ // 1- There is a change of the internal state.
3911
+ // 2- There is a change on the external api (ex: slots)
3912
+ //
3913
+ // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
3914
+ // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
3915
+ // in a reused VCustomElement, there won't be any slotted children.
3916
+ // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
3917
+ //
3918
+ // In case #2, we will always get a fresh VCustomElement.
3919
+ const children = vnode.aChildren || vnode.children;
3920
+ vm.aChildren = children;
3921
+ const {
3922
+ renderMode,
3923
+ shadowMode
3924
+ } = vm;
3925
+
3926
+ if (shadowMode === 1
3927
+ /* ShadowMode.Synthetic */
3928
+ || renderMode === 0
3929
+ /* RenderMode.Light */
3930
+ ) {
3931
+ // slow path
3932
+ allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
3933
+
3934
+ vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3935
+
3936
+ vnode.children = EmptyArray;
3937
+ }
3699
3938
  }
3939
+
3700
3940
  function createViewModelHook(elm, vnode, renderer) {
3701
- let vm = getAssociatedVMIfPresent(elm);
3702
- // There is a possibility that a custom element is registered under tagName, in which case, the
3703
- // initialization is already carry on, and there is nothing else to do here since this hook is
3704
- // called right after invoking `document.createElement`.
3705
- if (!isUndefined$1(vm)) {
3706
- return vm;
3707
- }
3708
- const { sel, mode, ctor, owner } = vnode;
3709
- vm = createVM(elm, ctor, renderer, {
3710
- mode,
3711
- owner,
3712
- tagName: sel,
3713
- });
3714
- if (process.env.NODE_ENV !== 'production') {
3715
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
3716
- }
3941
+ let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
3942
+ // initialization is already carry on, and there is nothing else to do here since this hook is
3943
+ // called right after invoking `document.createElement`.
3944
+
3945
+ if (!isUndefined$1(vm)) {
3717
3946
  return vm;
3947
+ }
3948
+
3949
+ const {
3950
+ sel,
3951
+ mode,
3952
+ ctor,
3953
+ owner
3954
+ } = vnode;
3955
+ vm = createVM(elm, ctor, renderer, {
3956
+ mode,
3957
+ owner,
3958
+ tagName: sel
3959
+ });
3960
+
3961
+ if (process.env.NODE_ENV !== 'production') {
3962
+ assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
3963
+ }
3964
+
3965
+ return vm;
3718
3966
  }
3967
+
3719
3968
  function allocateInSlot(vm, children) {
3720
- var _a;
3721
- const { cmpSlots: oldSlots } = vm;
3722
- const cmpSlots = (vm.cmpSlots = create(null));
3723
- for (let i = 0, len = children.length; i < len; i += 1) {
3724
- const vnode = children[i];
3725
- if (isNull(vnode)) {
3726
- continue;
3727
- }
3728
- let slotName = '';
3729
- if (isVBaseElement(vnode)) {
3730
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3731
- }
3732
- const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
3733
- ArrayPush$1.call(vnodes, vnode);
3734
- }
3735
- if (isFalse(vm.isDirty)) {
3736
- // We need to determine if the old allocation is really different from the new one
3737
- // and mark the vm as dirty
3738
- const oldKeys = keys(oldSlots);
3739
- if (oldKeys.length !== keys(cmpSlots).length) {
3740
- markComponentAsDirty(vm);
3741
- return;
3742
- }
3743
- for (let i = 0, len = oldKeys.length; i < len; i += 1) {
3744
- const key = oldKeys[i];
3745
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3746
- markComponentAsDirty(vm);
3747
- return;
3748
- }
3749
- const oldVNodes = oldSlots[key];
3750
- const vnodes = cmpSlots[key];
3751
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
3752
- if (oldVNodes[j] !== vnodes[j]) {
3753
- markComponentAsDirty(vm);
3754
- return;
3755
- }
3756
- }
3969
+ var _a;
3970
+
3971
+ const {
3972
+ cmpSlots: oldSlots
3973
+ } = vm;
3974
+ const cmpSlots = vm.cmpSlots = create(null);
3975
+
3976
+ for (let i = 0, len = children.length; i < len; i += 1) {
3977
+ const vnode = children[i];
3978
+
3979
+ if (isNull(vnode)) {
3980
+ continue;
3981
+ }
3982
+
3983
+ let slotName = '';
3984
+
3985
+ if (isVBaseElement(vnode)) {
3986
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3987
+ }
3988
+
3989
+ const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
3990
+ ArrayPush$1.call(vnodes, vnode);
3991
+ }
3992
+
3993
+ if (isFalse(vm.isDirty)) {
3994
+ // We need to determine if the old allocation is really different from the new one
3995
+ // and mark the vm as dirty
3996
+ const oldKeys = keys(oldSlots);
3997
+
3998
+ if (oldKeys.length !== keys(cmpSlots).length) {
3999
+ markComponentAsDirty(vm);
4000
+ return;
4001
+ }
4002
+
4003
+ for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4004
+ const key = oldKeys[i];
4005
+
4006
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4007
+ markComponentAsDirty(vm);
4008
+ return;
4009
+ }
4010
+
4011
+ const oldVNodes = oldSlots[key];
4012
+ const vnodes = cmpSlots[key];
4013
+
4014
+ for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4015
+ if (oldVNodes[j] !== vnodes[j]) {
4016
+ markComponentAsDirty(vm);
4017
+ return;
3757
4018
  }
4019
+ }
3758
4020
  }
3759
- }
3760
- // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3761
- const FromIteration = new WeakMap();
3762
- // dynamic children means it was generated by an iteration
4021
+ }
4022
+ } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4023
+
4024
+
4025
+ const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
3763
4026
  // in a template, and will require a more complex diffing algo.
4027
+
3764
4028
  function markAsDynamicChildren(children) {
3765
- FromIteration.set(children, 1);
4029
+ FromIteration.set(children, 1);
3766
4030
  }
4031
+
3767
4032
  function hasDynamicChildren(children) {
3768
- return FromIteration.has(children);
4033
+ return FromIteration.has(children);
3769
4034
  }
4035
+
3770
4036
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3771
- const map = {};
3772
- // TODO [#1637]: simplify this by assuming that all vnodes has keys
3773
- for (let j = beginIdx; j <= endIdx; ++j) {
3774
- const ch = children[j];
3775
- if (isVNode(ch)) {
3776
- const { key } = ch;
3777
- if (key !== undefined) {
3778
- map[key] = j;
3779
- }
3780
- }
4037
+ const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
4038
+
4039
+ for (let j = beginIdx; j <= endIdx; ++j) {
4040
+ const ch = children[j];
4041
+
4042
+ if (isVNode(ch)) {
4043
+ const {
4044
+ key
4045
+ } = ch;
4046
+
4047
+ if (key !== undefined) {
4048
+ map[key] = j;
4049
+ }
3781
4050
  }
3782
- return map;
4051
+ }
4052
+
4053
+ return map;
3783
4054
  }
4055
+
3784
4056
  function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3785
- let oldStartIdx = 0;
3786
- let newStartIdx = 0;
3787
- let oldEndIdx = oldCh.length - 1;
3788
- let oldStartVnode = oldCh[0];
3789
- let oldEndVnode = oldCh[oldEndIdx];
3790
- const newChEnd = newCh.length - 1;
3791
- let newEndIdx = newChEnd;
3792
- let newStartVnode = newCh[0];
3793
- let newEndVnode = newCh[newEndIdx];
3794
- let oldKeyToIdx;
3795
- let idxInOld;
3796
- let elmToMove;
3797
- let before;
3798
- let clonedOldCh = false;
3799
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3800
- if (!isVNode(oldStartVnode)) {
3801
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
3802
- }
3803
- else if (!isVNode(oldEndVnode)) {
3804
- oldEndVnode = oldCh[--oldEndIdx];
3805
- }
3806
- else if (!isVNode(newStartVnode)) {
3807
- newStartVnode = newCh[++newStartIdx];
3808
- }
3809
- else if (!isVNode(newEndVnode)) {
3810
- newEndVnode = newCh[--newEndIdx];
3811
- }
3812
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
3813
- patch(oldStartVnode, newStartVnode, renderer);
3814
- oldStartVnode = oldCh[++oldStartIdx];
3815
- newStartVnode = newCh[++newStartIdx];
3816
- }
3817
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
3818
- patch(oldEndVnode, newEndVnode, renderer);
3819
- oldEndVnode = oldCh[--oldEndIdx];
3820
- newEndVnode = newCh[--newEndIdx];
3821
- }
3822
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
3823
- // Vnode moved right
3824
- patch(oldStartVnode, newEndVnode, renderer);
3825
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3826
- oldStartVnode = oldCh[++oldStartIdx];
3827
- newEndVnode = newCh[--newEndIdx];
3828
- }
3829
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
3830
- // Vnode moved left
3831
- patch(oldEndVnode, newStartVnode, renderer);
3832
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3833
- oldEndVnode = oldCh[--oldEndIdx];
3834
- newStartVnode = newCh[++newStartIdx];
3835
- }
3836
- else {
3837
- if (oldKeyToIdx === undefined) {
3838
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
3839
- }
3840
- idxInOld = oldKeyToIdx[newStartVnode.key];
3841
- if (isUndefined$1(idxInOld)) {
3842
- // New element
3843
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3844
- newStartVnode = newCh[++newStartIdx];
3845
- }
3846
- else {
3847
- elmToMove = oldCh[idxInOld];
3848
- if (isVNode(elmToMove)) {
3849
- if (elmToMove.sel !== newStartVnode.sel) {
3850
- // New element
3851
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3852
- }
3853
- else {
3854
- patch(elmToMove, newStartVnode, renderer);
3855
- // Delete the old child, but copy the array since it is read-only.
3856
- // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3857
- // so we only care about the `oldCh` object inside this function.
3858
- // To avoid cloning over and over again, we check `clonedOldCh`
3859
- // and only clone once.
3860
- if (!clonedOldCh) {
3861
- clonedOldCh = true;
3862
- oldCh = [...oldCh];
3863
- }
3864
- // We've already cloned at least once, so it's no longer read-only
3865
- oldCh[idxInOld] = undefined;
3866
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
3867
- }
3868
- }
3869
- newStartVnode = newCh[++newStartIdx];
3870
- }
4057
+ let oldStartIdx = 0;
4058
+ let newStartIdx = 0;
4059
+ let oldEndIdx = oldCh.length - 1;
4060
+ let oldStartVnode = oldCh[0];
4061
+ let oldEndVnode = oldCh[oldEndIdx];
4062
+ const newChEnd = newCh.length - 1;
4063
+ let newEndIdx = newChEnd;
4064
+ let newStartVnode = newCh[0];
4065
+ let newEndVnode = newCh[newEndIdx];
4066
+ let oldKeyToIdx;
4067
+ let idxInOld;
4068
+ let elmToMove;
4069
+ let before;
4070
+ let clonedOldCh = false;
4071
+
4072
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4073
+ if (!isVNode(oldStartVnode)) {
4074
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
4075
+ } else if (!isVNode(oldEndVnode)) {
4076
+ oldEndVnode = oldCh[--oldEndIdx];
4077
+ } else if (!isVNode(newStartVnode)) {
4078
+ newStartVnode = newCh[++newStartIdx];
4079
+ } else if (!isVNode(newEndVnode)) {
4080
+ newEndVnode = newCh[--newEndIdx];
4081
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4082
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4083
+ oldStartVnode = oldCh[++oldStartIdx];
4084
+ newStartVnode = newCh[++newStartIdx];
4085
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4086
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4087
+ oldEndVnode = oldCh[--oldEndIdx];
4088
+ newEndVnode = newCh[--newEndIdx];
4089
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4090
+ // Vnode moved right
4091
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4092
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4093
+ oldStartVnode = oldCh[++oldStartIdx];
4094
+ newEndVnode = newCh[--newEndIdx];
4095
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4096
+ // Vnode moved left
4097
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4098
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4099
+ oldEndVnode = oldCh[--oldEndIdx];
4100
+ newStartVnode = newCh[++newStartIdx];
4101
+ } else {
4102
+ if (oldKeyToIdx === undefined) {
4103
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4104
+ }
4105
+
4106
+ idxInOld = oldKeyToIdx[newStartVnode.key];
4107
+
4108
+ if (isUndefined$1(idxInOld)) {
4109
+ // New element
4110
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4111
+ newStartVnode = newCh[++newStartIdx];
4112
+ } else {
4113
+ elmToMove = oldCh[idxInOld];
4114
+
4115
+ if (isVNode(elmToMove)) {
4116
+ if (elmToMove.sel !== newStartVnode.sel) {
4117
+ // New element
4118
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4119
+ } else {
4120
+ patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
4121
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4122
+ // so we only care about the `oldCh` object inside this function.
4123
+ // To avoid cloning over and over again, we check `clonedOldCh`
4124
+ // and only clone once.
4125
+
4126
+ if (!clonedOldCh) {
4127
+ clonedOldCh = true;
4128
+ oldCh = [...oldCh];
4129
+ } // We've already cloned at least once, so it's no longer read-only
4130
+
4131
+
4132
+ oldCh[idxInOld] = undefined;
4133
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4134
+ }
3871
4135
  }
4136
+
4137
+ newStartVnode = newCh[++newStartIdx];
4138
+ }
3872
4139
  }
3873
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
3874
- if (oldStartIdx > oldEndIdx) {
3875
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3876
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3877
- let i = newEndIdx;
3878
- let n;
3879
- do {
3880
- n = newCh[++i];
3881
- } while (!isVNode(n) && i < newChEnd);
3882
- before = isVNode(n) ? n.elm : null;
3883
- mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3884
- }
3885
- else {
3886
- unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
3887
- }
4140
+ }
4141
+
4142
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4143
+ if (oldStartIdx > oldEndIdx) {
4144
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4145
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4146
+ let i = newEndIdx;
4147
+ let n;
4148
+
4149
+ do {
4150
+ n = newCh[++i];
4151
+ } while (!isVNode(n) && i < newChEnd);
4152
+
4153
+ before = isVNode(n) ? n.elm : null;
4154
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4155
+ } else {
4156
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
3888
4157
  }
4158
+ }
3889
4159
  }
4160
+
3890
4161
  function updateStaticChildren(c1, c2, parent, renderer) {
3891
- const c1Length = c1.length;
3892
- const c2Length = c2.length;
3893
- if (c1Length === 0) {
3894
- // the old list is empty, we can directly insert anything new
3895
- mountVNodes(c2, parent, renderer, null);
3896
- return;
3897
- }
3898
- if (c2Length === 0) {
3899
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3900
- // this is the case in which the dynamic children of an if-directive should be removed
3901
- unmountVNodes(c1, parent, renderer, true);
3902
- return;
3903
- }
3904
- // if the old list is not empty, the new list MUST have the same
3905
- // amount of nodes, that's why we call this static children
3906
- let anchor = null;
3907
- for (let i = c2Length - 1; i >= 0; i -= 1) {
3908
- const n1 = c1[i];
3909
- const n2 = c2[i];
3910
- if (n2 !== n1) {
3911
- if (isVNode(n1)) {
3912
- if (isVNode(n2)) {
3913
- // both vnodes are equivalent, and we just need to patch them
3914
- patch(n1, n2, renderer);
3915
- anchor = n2.elm;
3916
- }
3917
- else {
3918
- // removing the old vnode since the new one is null
3919
- unmount(n1, parent, renderer, true);
3920
- }
3921
- }
3922
- else if (isVNode(n2)) {
3923
- mount(n2, parent, renderer, anchor);
3924
- anchor = n2.elm;
3925
- }
4162
+ const c1Length = c1.length;
4163
+ const c2Length = c2.length;
4164
+
4165
+ if (c1Length === 0) {
4166
+ // the old list is empty, we can directly insert anything new
4167
+ mountVNodes(c2, parent, renderer, null);
4168
+ return;
4169
+ }
4170
+
4171
+ if (c2Length === 0) {
4172
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4173
+ // this is the case in which the dynamic children of an if-directive should be removed
4174
+ unmountVNodes(c1, parent, renderer, true);
4175
+ return;
4176
+ } // if the old list is not empty, the new list MUST have the same
4177
+ // amount of nodes, that's why we call this static children
4178
+
4179
+
4180
+ let anchor = null;
4181
+
4182
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4183
+ const n1 = c1[i];
4184
+ const n2 = c2[i];
4185
+
4186
+ if (n2 !== n1) {
4187
+ if (isVNode(n1)) {
4188
+ if (isVNode(n2)) {
4189
+ // both vnodes are equivalent, and we just need to patch them
4190
+ patch(n1, n2, parent, renderer);
4191
+ anchor = n2.elm;
4192
+ } else {
4193
+ // removing the old vnode since the new one is null
4194
+ unmount(n1, parent, renderer, true);
3926
4195
  }
4196
+ } else if (isVNode(n2)) {
4197
+ mount(n2, parent, renderer, anchor);
4198
+ anchor = n2.elm;
4199
+ }
3927
4200
  }
4201
+ }
3928
4202
  }
3929
4203
 
3930
4204
  /*
@@ -4245,13 +4519,6 @@ function fid(url) {
4245
4519
  }
4246
4520
  return url;
4247
4521
  }
4248
- /**
4249
- * Map to store an index value assigned to any dynamic component reference ingested
4250
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4251
- * component reference to avoid diffing algo mismatches.
4252
- */
4253
- const DynamicImportedComponentMap = new Map();
4254
- let dynamicImportedComponentCounter = 0;
4255
4522
  /**
4256
4523
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4257
4524
  */
@@ -4268,18 +4535,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4268
4535
  if (!isComponentConstructor(Ctor)) {
4269
4536
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4270
4537
  }
4271
- let idx = DynamicImportedComponentMap.get(Ctor);
4272
- if (isUndefined$1(idx)) {
4273
- idx = dynamicImportedComponentCounter++;
4274
- DynamicImportedComponentMap.set(Ctor, idx);
4275
- }
4276
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4277
- // to identify different constructors as vnodes with different keys to avoid reusing the
4278
- // element used for previous constructors.
4279
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4280
- // hoisting optimization.
4281
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4282
- return c(sel, Ctor, newData, children);
4538
+ return c(sel, Ctor, data, children);
4283
4539
  }
4284
4540
  /**
4285
4541
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5005,7 +5261,7 @@ function createVM(elm, ctor, renderer, options) {
5005
5261
  return `[object:vm ${def.name} (${vm.idx})]`;
5006
5262
  };
5007
5263
 
5008
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5264
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5009
5265
  vm.shadowMode = 0
5010
5266
  /* ShadowMode.Native */
5011
5267
  ;
@@ -5044,7 +5300,7 @@ function computeShadowMode(vm, renderer) {
5044
5300
  } else if (isNativeShadowDefined) {
5045
5301
  // Not combined with above condition because @lwc/features only supports identifiers in
5046
5302
  // the if-condition.
5047
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5303
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5048
5304
  if (def.shadowSupportMode === "any"
5049
5305
  /* ShadowSupportMode.Any */
5050
5306
  ) {
@@ -5173,13 +5429,10 @@ function runRenderedCallback(vm) {
5173
5429
  const {
5174
5430
  def: {
5175
5431
  renderedCallback
5176
- },
5177
- renderer: {
5178
- ssr
5179
5432
  }
5180
5433
  } = vm;
5181
5434
 
5182
- if (isTrue(ssr)) {
5435
+ if (!process.env.IS_BROWSER) {
5183
5436
  return;
5184
5437
  }
5185
5438
 
@@ -5432,13 +5685,7 @@ function resetComponentRoot(vm) {
5432
5685
  vm.velements = EmptyArray;
5433
5686
  }
5434
5687
  function scheduleRehydration(vm) {
5435
- const {
5436
- renderer: {
5437
- ssr
5438
- }
5439
- } = vm;
5440
-
5441
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5688
+ if (!process.env.IS_BROWSER || isTrue(vm.isScheduled)) {
5442
5689
  return;
5443
5690
  }
5444
5691
 
@@ -5545,15 +5792,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5545
5792
  }
5546
5793
 
5547
5794
  function createFieldDataCallback(vm, name) {
5548
- const {
5549
- cmpFields
5550
- } = vm;
5551
5795
  return value => {
5552
- if (value !== vm.cmpFields[name]) {
5553
- // storing the value in the underlying storage
5554
- cmpFields[name] = value;
5555
- componentValueMutated(vm, name);
5556
- }
5796
+ updateComponentValue(vm, name, value);
5557
5797
  };
5558
5798
  }
5559
5799
 
@@ -5771,7 +6011,7 @@ function installWireAdapters(vm) {
5771
6011
  ArrayPush$1.call(wiredConnecting, () => {
5772
6012
  connector.connect();
5773
6013
 
5774
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6014
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5775
6015
  if (hasDynamicParams) {
5776
6016
  Promise.resolve().then(computeConfigAndUpdate);
5777
6017
  return;
@@ -5917,6 +6157,7 @@ function hydrateNode(node, vnode, renderer) {
5917
6157
  }
5918
6158
  return renderer.nextSibling(hydratedNode);
5919
6159
  }
6160
+ const NODE_VALUE_PROP = 'nodeValue';
5920
6161
  function hydrateText(node, vnode, renderer) {
5921
6162
  var _a;
5922
6163
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -5924,7 +6165,7 @@ function hydrateText(node, vnode, renderer) {
5924
6165
  }
5925
6166
  if (process.env.NODE_ENV !== 'production') {
5926
6167
  const { getProperty } = renderer;
5927
- const nodeValue = getProperty(node, 'nodeValue');
6168
+ const nodeValue = getProperty(node, NODE_VALUE_PROP);
5928
6169
  if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
5929
6170
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
5930
6171
  }
@@ -5941,13 +6182,13 @@ function hydrateComment(node, vnode, renderer) {
5941
6182
  }
5942
6183
  if (process.env.NODE_ENV !== 'production') {
5943
6184
  const { getProperty } = renderer;
5944
- const nodeValue = getProperty(node, 'nodeValue');
6185
+ const nodeValue = getProperty(node, NODE_VALUE_PROP);
5945
6186
  if (nodeValue !== vnode.text) {
5946
6187
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
5947
6188
  }
5948
6189
  }
5949
6190
  const { setProperty } = renderer;
5950
- setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6191
+ setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5951
6192
  vnode.elm = node;
5952
6193
  return node;
5953
6194
  }
@@ -6215,13 +6456,13 @@ function areCompatibleNodes(client, ssr, vnode, renderer) {
6215
6456
  if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
6216
6457
  return false;
6217
6458
  }
6218
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6459
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
6219
6460
  }
6220
6461
  if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
6221
6462
  if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
6222
6463
  return false;
6223
6464
  }
6224
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
6465
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
6225
6466
  }
6226
6467
  if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
6227
6468
  return false;
@@ -6379,4 +6620,4 @@ function getComponentConstructor(elm) {
6379
6620
  }
6380
6621
 
6381
6622
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6382
- /* version: 2.22.0 */
6623
+ /* version: 2.23.2 */