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