@lwc/engine-core 8.12.6 → 8.12.7-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/framework/api.d.ts +0 -1
  2. package/dist/framework/attributes.d.ts +1 -0
  3. package/dist/framework/base-bridge-element.d.ts +0 -1
  4. package/dist/framework/base-lightning-element.d.ts +0 -1
  5. package/dist/framework/check-version-mismatch.d.ts +0 -1
  6. package/dist/framework/component.d.ts +0 -1
  7. package/dist/framework/decorators/api.d.ts +0 -1
  8. package/dist/framework/decorators/register.d.ts +0 -1
  9. package/dist/framework/decorators/track.d.ts +0 -1
  10. package/dist/framework/decorators/wire.d.ts +3 -2
  11. package/dist/framework/def.d.ts +0 -1
  12. package/dist/framework/fragment-cache.d.ts +0 -1
  13. package/dist/framework/freeze-template.d.ts +0 -1
  14. package/dist/framework/get-component-constructor.d.ts +0 -1
  15. package/dist/framework/hot-swaps.d.ts +0 -1
  16. package/dist/framework/html-element.d.ts +0 -1
  17. package/dist/framework/html-properties.d.ts +0 -1
  18. package/dist/framework/hydration.d.ts +0 -1
  19. package/dist/framework/invoker.d.ts +1 -3
  20. package/dist/framework/main.d.ts +0 -1
  21. package/dist/framework/membrane.d.ts +0 -1
  22. package/dist/framework/modules/attrs.d.ts +0 -1
  23. package/dist/framework/modules/computed-class-attr.d.ts +0 -1
  24. package/dist/framework/modules/computed-style-attr.d.ts +0 -1
  25. package/dist/framework/modules/events.d.ts +0 -1
  26. package/dist/framework/modules/props.d.ts +0 -1
  27. package/dist/framework/modules/refs.d.ts +0 -1
  28. package/dist/framework/modules/static-class-attr.d.ts +0 -1
  29. package/dist/framework/modules/static-parts.d.ts +0 -1
  30. package/dist/framework/modules/static-style-attr.d.ts +0 -1
  31. package/dist/framework/modules/text.d.ts +0 -1
  32. package/dist/framework/mutation-logger.d.ts +0 -1
  33. package/dist/framework/mutation-tracker.d.ts +0 -1
  34. package/dist/framework/observed-fields.d.ts +0 -1
  35. package/dist/framework/overridable-hooks.d.ts +6 -0
  36. package/dist/framework/profiler.d.ts +3 -5
  37. package/dist/framework/readonly.d.ts +0 -1
  38. package/dist/framework/renderer.d.ts +0 -1
  39. package/dist/framework/rendering.d.ts +0 -1
  40. package/dist/framework/reporting.d.ts +0 -1
  41. package/dist/framework/restrictions.d.ts +0 -1
  42. package/dist/framework/runtime-instrumentation.d.ts +0 -1
  43. package/dist/framework/sanitized-html-content.d.ts +7 -2
  44. package/dist/framework/secure-template.d.ts +0 -1
  45. package/dist/framework/shadow-migration-mode.d.ts +0 -1
  46. package/dist/framework/stylesheet.d.ts +0 -1
  47. package/dist/framework/template.d.ts +0 -1
  48. package/dist/framework/update-component-value.d.ts +0 -1
  49. package/dist/framework/utils.d.ts +0 -2
  50. package/dist/framework/vm.d.ts +0 -1
  51. package/dist/framework/vnodes.d.ts +0 -1
  52. package/dist/framework/weak-multimap.d.ts +0 -1
  53. package/dist/framework/wiring/context.d.ts +0 -1
  54. package/dist/framework/wiring/index.d.ts +0 -1
  55. package/dist/framework/wiring/types.d.ts +0 -1
  56. package/dist/framework/wiring/wiring.d.ts +0 -1
  57. package/dist/index.cjs.js +130 -197
  58. package/dist/index.d.ts +0 -1
  59. package/dist/index.js +130 -197
  60. package/dist/libs/aria-reflection/aria-reflection.d.ts +1 -0
  61. package/dist/libs/aria-reflection/attr-reflection.d.ts +2 -0
  62. package/dist/libs/mutation-tracker/index.d.ts +0 -1
  63. package/dist/libs/reflection/aria-reflection.d.ts +0 -1
  64. package/dist/libs/reflection/attr-reflection.d.ts +0 -1
  65. package/dist/libs/reflection/index.d.ts +0 -1
  66. package/dist/libs/signal-tracker/index.d.ts +0 -1
  67. package/dist/patches/detect-non-standard-aria.d.ts +0 -1
  68. package/dist/patches/detect-synthetic-cross-root-aria.d.ts +0 -1
  69. package/dist/shared/circular-module-dependencies.d.ts +0 -1
  70. package/dist/shared/error.d.ts +0 -1
  71. package/dist/shared/format.d.ts +0 -1
  72. package/dist/shared/logger.d.ts +0 -1
  73. package/package.json +5 -5
package/dist/index.cjs.js CHANGED
@@ -251,16 +251,6 @@ function shouldBeFormAssociated(Ctor) {
251
251
  }
252
252
  return ctorFormAssociated && apiFeatureEnabled;
253
253
  }
254
- // check if a property is in an object, and if the object throws an error merely because we are
255
- // checking if the property exists, return false
256
- function safeHasProp(obj, prop) {
257
- try {
258
- return prop in obj;
259
- }
260
- catch (_err) {
261
- return false;
262
- }
263
- }
264
254
 
265
255
  /*
266
256
  * Copyright (c) 2024, Salesforce, Inc.
@@ -601,14 +591,14 @@ function componentValueObserved(vm, key, target = {}) {
601
591
  valueObserved(component, key);
602
592
  }
603
593
  // The portion of reactivity that's exposed to signals is to subscribe a callback to re-render the VM (templates).
604
- // We check the following to ensure re-render is subscribed at the correct time.
594
+ // We check check the following to ensure re-render is subscribed at the correct time.
605
595
  // 1. The template is currently being rendered (there is a template reactive observer)
606
596
  // 2. There was a call to a getter to access the signal (happens during vnode generation)
607
597
  if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS &&
608
598
  shared.isObject(target) &&
609
599
  !shared.isNull(target) &&
610
- safeHasProp(target, 'value') &&
611
- safeHasProp(target, 'subscribe') &&
600
+ 'value' in target &&
601
+ 'subscribe' in target &&
612
602
  shared.isFunction(target.subscribe) &&
613
603
  shared.isTrustedSignal(target) &&
614
604
  // Only subscribe if a template is being rendered by the engine
@@ -2960,10 +2950,7 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
2960
2950
  const { observedAttributes: superObservedAttributes = [] } = SuperClass;
2961
2951
  const descriptors = shared.create(null);
2962
2952
  // present a hint message so that developers are aware that they have not decorated property with @api
2963
- // Note that we also don't do this in SSR because we cannot sniff for what props are declared on
2964
- // HTMLElementPrototype, and it seems not worth it to have these dev-only warnings there, since
2965
- // an `in` check could mistakenly assume that a prop is declared on a LightningElement prototype.
2966
- if (process.env.NODE_ENV !== 'production' && process.env.IS_BROWSER) {
2953
+ if (process.env.NODE_ENV !== 'production') {
2967
2954
  // TODO [#3761]: enable for components that don't extend from LightningElement
2968
2955
  if (!shared.isUndefined(proto) && !shared.isNull(proto) && !hasCustomSuperClass) {
2969
2956
  const nonPublicPropertiesToWarnOn = new Set([
@@ -3980,6 +3967,15 @@ function safelySetProperty(setProperty, elm, key, value) {
3980
3967
  setProperty(elm, key, value);
3981
3968
  }
3982
3969
  }
3970
+ /**
3971
+ * Given two objects (likely either a string or a SanitizedHtmlContent object), return true if their
3972
+ * string values are equivalent.
3973
+ * @param first
3974
+ * @param second
3975
+ */
3976
+ function isSanitizedHtmlContentEqual(first, second) {
3977
+ return unwrapIfNecessary(first) === unwrapIfNecessary(second);
3978
+ }
3983
3979
 
3984
3980
  /*
3985
3981
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5824,9 +5820,8 @@ const operationIdNameMapping = [
5824
5820
  'renderedCallback',
5825
5821
  'disconnectedCallback',
5826
5822
  'errorCallback',
5827
- 'lwc-render',
5828
- 'lwc-rerender',
5829
- 'lwc-ssr-hydrate',
5823
+ 'lwc-hydrate',
5824
+ 'lwc-rehydrate',
5830
5825
  ];
5831
5826
  const operationTooltipMapping = [
5832
5827
  // constructor
@@ -5843,12 +5838,10 @@ const operationTooltipMapping = [
5843
5838
  'component disconnectedCallback()',
5844
5839
  // errorCallback
5845
5840
  'component errorCallback()',
5846
- // lwc-render
5841
+ // lwc-hydrate
5847
5842
  'component first rendered',
5848
- // lwc-rerender
5843
+ // lwc-rehydrate
5849
5844
  'component re-rendered',
5850
- // lwc-ssr-hydrate
5851
- 'component hydrated from server-rendered HTML',
5852
5845
  ];
5853
5846
  // Even if all the browser the engine supports implements the UserTiming API, we need to guard the measure APIs.
5854
5847
  // JSDom (used in Jest) for example doesn't implement the UserTiming APIs.
@@ -5902,14 +5895,13 @@ function getProperties(vm) {
5902
5895
  function getColor(opId) {
5903
5896
  // As of Sept 2024: primary (dark blue), secondary (light blue), tertiary (green)
5904
5897
  switch (opId) {
5905
- // GlobalSsrHydrate, GlobalRender, and Constructor tend to occur at the top level
5906
- case 7 /* OperationId.GlobalRender */:
5907
- case 9 /* OperationId.GlobalSsrHydrate */:
5898
+ // GlobalHydrate and Constructor tend to occur at the top level
5899
+ case 7 /* OperationId.GlobalHydrate */:
5908
5900
  case 0 /* OperationId.Constructor */:
5909
5901
  return 'primary';
5910
- // GlobalRerender also occurs at the top level, but we want to use tertiary (green) because it's easier to
5902
+ // GlobalRehydrate also occurs at the top level, but we want to use tertiary (green) because it's easier to
5911
5903
  // distinguish from primary, and at a glance you should be able to easily tell re-renders from first renders.
5912
- case 8 /* OperationId.GlobalRerender */:
5904
+ case 8 /* OperationId.GlobalRehydrate */:
5913
5905
  return 'tertiary';
5914
5906
  // Everything else (patch/render/callbacks)
5915
5907
  default:
@@ -6114,7 +6106,7 @@ function getVMBeingRendered() {
6114
6106
  function setVMBeingRendered(vm) {
6115
6107
  vmBeingRendered = vm;
6116
6108
  }
6117
- const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_]+$/;
6109
+ const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_.]+$/;
6118
6110
  // See W-16614556
6119
6111
  // TODO [#2826]: freeze the template object
6120
6112
  function isValidScopeToken(token) {
@@ -6482,10 +6474,7 @@ function invokeComponentConstructor(vm, Ctor) {
6482
6474
  // the "instanceof" operator would not work here since Locker Service provides its own
6483
6475
  // implementation of LightningElement, so we indirectly check if the base constructor is
6484
6476
  // invoked by accessing the component on the vm.
6485
- const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6486
- ? vmBeingConstructed.component !== result
6487
- : !(result instanceof LightningElement);
6488
- if (isInvalidConstructor) {
6477
+ if (vmBeingConstructed.component !== result) {
6489
6478
  throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
6490
6479
  }
6491
6480
  }
@@ -6671,10 +6660,10 @@ function connectRootElement(elm) {
6671
6660
  const vm = getAssociatedVM(elm);
6672
6661
  if (process.env.NODE_ENV !== 'production') {
6673
6662
  // Flush any logs for this VM so that the initial properties from the constructor don't "count"
6674
- // in subsequent re-renders (lwc-rerender). Right now we're at the first render (lwc-hydrate).
6663
+ // in subsequent re-renders (lwc-rehydrate). Right now we're at the first render (lwc-hydrate).
6675
6664
  flushMutationLogsForVM(vm);
6676
6665
  }
6677
- logGlobalOperationStartWithVM(7 /* OperationId.GlobalRender */, vm);
6666
+ logGlobalOperationStartWithVM(7 /* OperationId.GlobalHydrate */, vm);
6678
6667
  // Usually means moving the element from one place to another, which is observable via
6679
6668
  // life-cycle hooks.
6680
6669
  if (vm.state === 1 /* VMState.connected */) {
@@ -6682,7 +6671,7 @@ function connectRootElement(elm) {
6682
6671
  }
6683
6672
  runConnectedCallback(vm);
6684
6673
  rehydrate(vm);
6685
- logGlobalOperationEndWithVM(7 /* OperationId.GlobalRender */, vm);
6674
+ logGlobalOperationEndWithVM(7 /* OperationId.GlobalHydrate */, vm);
6686
6675
  }
6687
6676
  function disconnectRootElement(elm) {
6688
6677
  const vm = getAssociatedVM(elm);
@@ -6991,7 +6980,7 @@ function flushRehydrationQueue() {
6991
6980
  // Gather the logs before rehydration starts so they can be reported at the end of rehydration.
6992
6981
  // Note that we also clear all existing logs at this point so that subsequent re-renders start from a clean slate.
6993
6982
  const mutationLogs = process.env.NODE_ENV === 'production' ? undefined : getAndFlushMutationLogs();
6994
- logGlobalOperationStart(8 /* OperationId.GlobalRerender */);
6983
+ logGlobalOperationStart(8 /* OperationId.GlobalRehydrate */);
6995
6984
  if (process.env.NODE_ENV !== 'production') {
6996
6985
  shared.assert.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
6997
6986
  }
@@ -7011,13 +7000,13 @@ function flushRehydrationQueue() {
7011
7000
  shared.ArrayUnshift.apply(rehydrateQueue, shared.ArraySlice.call(vms, i + 1));
7012
7001
  }
7013
7002
  // we need to end the measure before throwing.
7014
- logGlobalOperationEnd(8 /* OperationId.GlobalRerender */, mutationLogs);
7003
+ logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */, mutationLogs);
7015
7004
  // re-throwing the original error will break the current tick, but since the next tick is
7016
7005
  // already scheduled, it should continue patching the rest.
7017
7006
  throw error;
7018
7007
  }
7019
7008
  }
7020
- logGlobalOperationEnd(8 /* OperationId.GlobalRerender */, mutationLogs);
7009
+ logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */, mutationLogs);
7021
7010
  }
7022
7011
  function runConnectedCallback(vm) {
7023
7012
  const { state } = vm;
@@ -7539,78 +7528,6 @@ if (process.env.IS_BROWSER && isGlobalAriaPolyfillLoaded()) {
7539
7528
  }
7540
7529
  }
7541
7530
 
7542
- /*
7543
- * Copyright (c) 2024, Salesforce, Inc.
7544
- * All rights reserved.
7545
- * SPDX-License-Identifier: MIT
7546
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7547
- */
7548
- // Errors that occured during the hydration process
7549
- let hydrationErrors = [];
7550
- /*
7551
- Prints attributes as null or "value"
7552
- */
7553
- function prettyPrintAttribute(attribute, value) {
7554
- assertNotProd(); // this method should never leak to prod
7555
- return `${attribute}=${shared.isNull(value) || shared.isUndefined(value) ? value : `"${value}"`}`;
7556
- }
7557
- /*
7558
- Sorts and stringifies classes
7559
- */
7560
- function prettyPrintClasses(classes) {
7561
- assertNotProd(); // this method should never leak to prod
7562
- const value = JSON.stringify(shared.ArrayJoin.call(shared.ArraySort.call(shared.ArrayFrom(classes)), ' '));
7563
- return `class=${value}`;
7564
- }
7565
- /*
7566
- Hydration errors occur before the source node has been fully hydrated,
7567
- queue them so they can be logged later against the mounted node.
7568
- */
7569
- function queueHydrationError(type, serverRendered, clientExpected) {
7570
- assertNotProd(); // this method should never leak to prod
7571
- shared.ArrayPush.call(hydrationErrors, { type, serverRendered, clientExpected });
7572
- }
7573
- /*
7574
- Flushes (logs) any queued errors after the source node has been mounted.
7575
- */
7576
- function flushHydrationErrors(source) {
7577
- assertNotProd(); // this method should never leak to prod
7578
- for (const hydrationError of hydrationErrors) {
7579
- logHydrationWarning(`Hydration ${hydrationError.type} mismatch on:`, source, `\n- rendered on server:`, hydrationError.serverRendered, `\n- expected on client:`, hydrationError.clientExpected || source);
7580
- }
7581
- hydrationErrors = [];
7582
- }
7583
- function isTypeElement(node) {
7584
- const isCorrectType = node?.nodeType === 1 /* EnvNodeTypes.ELEMENT */;
7585
- if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
7586
- queueHydrationError('node', node);
7587
- }
7588
- return isCorrectType;
7589
- }
7590
- function isTypeText(node) {
7591
- const isCorrectType = node?.nodeType === 3 /* EnvNodeTypes.TEXT */;
7592
- if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
7593
- queueHydrationError('node', node);
7594
- }
7595
- return isCorrectType;
7596
- }
7597
- function isTypeComment(node) {
7598
- const isCorrectType = node?.nodeType === 8 /* EnvNodeTypes.COMMENT */;
7599
- if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
7600
- queueHydrationError('node', node);
7601
- }
7602
- return isCorrectType;
7603
- }
7604
- /*
7605
- logger.ts converts all args to a string, losing object referenences and has
7606
- legacy bloat which would have meant more pathing.
7607
- */
7608
- function logHydrationWarning(...args) {
7609
- assertNotProd(); // this method should never leak to prod
7610
- /* eslint-disable-next-line no-console */
7611
- console.warn('[LWC warn:', ...args);
7612
- }
7613
-
7614
7531
  /*
7615
7532
  * Copyright (c) 2022, salesforce.com, inc.
7616
7533
  * All rights reserved.
@@ -7623,20 +7540,11 @@ const EMPTY_SET = new Set();
7623
7540
  let hasMismatch = false;
7624
7541
  function hydrateRoot(vm) {
7625
7542
  hasMismatch = false;
7626
- logGlobalOperationStartWithVM(9 /* OperationId.GlobalSsrHydrate */, vm);
7627
7543
  runConnectedCallback(vm);
7628
7544
  hydrateVM(vm);
7629
- if (process.env.NODE_ENV !== 'production') {
7630
- /*
7631
- Errors are queued as they occur and then logged with the source element once it has been hydrated and mounted to the DOM.
7632
- Means the element in the console matches what is on the page and the highlighting works properly when you hover over the elements in the console.
7633
- */
7634
- flushHydrationErrors(vm.renderRoot);
7635
- if (hasMismatch) {
7636
- logHydrationWarning('Hydration completed with errors.');
7637
- }
7545
+ if (hasMismatch && process.env.NODE_ENV !== 'production') {
7546
+ logWarn('Hydration completed with errors.', vm);
7638
7547
  }
7639
- logGlobalOperationEndWithVM(9 /* OperationId.GlobalSsrHydrate */, vm);
7640
7548
  }
7641
7549
  function hydrateVM(vm) {
7642
7550
  const children = renderComponent(vm);
@@ -7644,9 +7552,7 @@ function hydrateVM(vm) {
7644
7552
  // reset the refs; they will be set during `hydrateChildren`
7645
7553
  resetRefVNodes(vm);
7646
7554
  const { renderRoot: parentNode, renderer: { getFirstChild }, } = vm;
7647
- logOperationStart(2 /* OperationId.Patch */, vm);
7648
7555
  hydrateChildren(getFirstChild(parentNode), children, parentNode, vm, false);
7649
- logOperationEnd(2 /* OperationId.Patch */, vm);
7650
7556
  runRenderedCallback(vm);
7651
7557
  }
7652
7558
  function hydrateNode(node, vnode, renderer) {
@@ -7675,25 +7581,21 @@ function hydrateNode(node, vnode, renderer) {
7675
7581
  hydratedNode = hydrateCustomElement(node, vnode, vnode.data.renderer ?? renderer);
7676
7582
  break;
7677
7583
  }
7678
- if (process.env.NODE_ENV !== 'production') {
7679
- /*
7680
- Errors are queued as they occur and then logged with the source element once it has been hydrated and mounted to the DOM.
7681
- Means the element in the console matches what is on the page and the highlighting works properly when you hover over the elements in the console.
7682
- */
7683
- flushHydrationErrors(hydratedNode);
7684
- }
7685
7584
  return renderer.nextSibling(hydratedNode);
7686
7585
  }
7687
7586
  const NODE_VALUE_PROP = 'nodeValue';
7688
- function validateTextNodeEquality(node, vnode, renderer) {
7587
+ function textNodeContentsAreEqual(node, vnode, renderer) {
7689
7588
  const { getProperty } = renderer;
7690
7589
  const nodeValue = getProperty(node, NODE_VALUE_PROP);
7691
- if (nodeValue !== vnode.text &&
7692
- // Special case for empty text nodes – these are serialized differently on the server
7693
- // See https://github.com/salesforce/lwc/pull/2656
7694
- (nodeValue !== '\u200D' || vnode.text !== '')) {
7695
- queueHydrationError('text content', nodeValue, vnode.text);
7590
+ if (nodeValue === vnode.text) {
7591
+ return true;
7592
+ }
7593
+ // Special case for empty text nodes these are serialized differently on the server
7594
+ // See https://github.com/salesforce/lwc/pull/2656
7595
+ if (nodeValue === '\u200D' && vnode.text === '') {
7596
+ return true;
7696
7597
  }
7598
+ return false;
7697
7599
  }
7698
7600
  // The validationOptOut static property can be an array of attribute names.
7699
7601
  // Any attribute names specified in that array will not be validated, and the
@@ -7716,7 +7618,7 @@ function getValidationPredicate(elm, renderer, optOutStaticProp) {
7716
7618
  !shared.isUndefined(optOutStaticProp) &&
7717
7619
  !shared.isTrue(optOutStaticProp) &&
7718
7620
  !isValidArray) {
7719
- logHydrationWarning('`validationOptOut` must be `true` or an array of attributes that should not be validated.');
7621
+ logWarn('`validationOptOut` must be `true` or an array of attributes that should not be validated.');
7720
7622
  }
7721
7623
  return (attrName) => {
7722
7624
  // Component wants to opt out of all validation
@@ -7736,14 +7638,16 @@ function getValidationPredicate(elm, renderer, optOutStaticProp) {
7736
7638
  };
7737
7639
  }
7738
7640
  function hydrateText(node, vnode, renderer) {
7739
- if (!isTypeText(node)) {
7641
+ if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
7740
7642
  return handleMismatch(node, vnode, renderer);
7741
7643
  }
7742
- return updateTextContent(node, vnode, renderer);
7644
+ return updateTextContent(node, vnode, vnode.owner, renderer);
7743
7645
  }
7744
- function updateTextContent(node, vnode, renderer) {
7646
+ function updateTextContent(node, vnode, owner, renderer) {
7745
7647
  if (process.env.NODE_ENV !== 'production') {
7746
- validateTextNodeEquality(node, vnode, renderer);
7648
+ if (!textNodeContentsAreEqual(node, vnode, renderer)) {
7649
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', owner);
7650
+ }
7747
7651
  }
7748
7652
  const { setText } = renderer;
7749
7653
  setText(node, vnode.text ?? null);
@@ -7751,14 +7655,14 @@ function updateTextContent(node, vnode, renderer) {
7751
7655
  return node;
7752
7656
  }
7753
7657
  function hydrateComment(node, vnode, renderer) {
7754
- if (!isTypeComment(node)) {
7658
+ if (!hasCorrectNodeType(vnode, node, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
7755
7659
  return handleMismatch(node, vnode, renderer);
7756
7660
  }
7757
7661
  if (process.env.NODE_ENV !== 'production') {
7758
7662
  const { getProperty } = renderer;
7759
7663
  const nodeValue = getProperty(node, NODE_VALUE_PROP);
7760
7664
  if (nodeValue !== vnode.text) {
7761
- queueHydrationError('comment', nodeValue, vnode.text);
7665
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
7762
7666
  }
7763
7667
  }
7764
7668
  const { setProperty } = renderer;
@@ -7769,12 +7673,11 @@ function hydrateComment(node, vnode, renderer) {
7769
7673
  return node;
7770
7674
  }
7771
7675
  function hydrateStaticElement(elm, vnode, renderer) {
7772
- if (isTypeElement(elm) &&
7773
- isTypeElement(vnode.fragment) &&
7774
- areStaticElementsCompatible(vnode.fragment, elm, vnode, renderer)) {
7775
- return hydrateStaticElementParts(elm, vnode, renderer);
7676
+ if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
7677
+ !areCompatibleStaticNodes(vnode.fragment, elm, vnode, renderer)) {
7678
+ return handleMismatch(elm, vnode, renderer);
7776
7679
  }
7777
- return handleMismatch(elm, vnode, renderer);
7680
+ return hydrateStaticElementParts(elm, vnode, renderer);
7778
7681
  }
7779
7682
  function hydrateStaticElementParts(elm, vnode, renderer) {
7780
7683
  const { parts } = vnode;
@@ -7797,7 +7700,8 @@ function hydrateFragment(elm, vnode, renderer) {
7797
7700
  return (vnode.elm = children[children.length - 1].elm);
7798
7701
  }
7799
7702
  function hydrateElement(elm, vnode, renderer) {
7800
- if (!isTypeElement(elm) || !isMatchingElement(vnode, elm, renderer)) {
7703
+ if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
7704
+ !isMatchingElement(vnode, elm, renderer)) {
7801
7705
  return handleMismatch(elm, vnode, renderer);
7802
7706
  }
7803
7707
  vnode.elm = elm;
@@ -7810,17 +7714,17 @@ function hydrateElement(elm, vnode, renderer) {
7810
7714
  const { data: { props }, } = vnode;
7811
7715
  const { getProperty } = renderer;
7812
7716
  if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
7813
- const unwrappedServerInnerHTML = unwrapIfNecessary(getProperty(elm, 'innerHTML'));
7814
- const unwrappedClientInnerHTML = unwrapIfNecessary(props.innerHTML);
7815
- if (unwrappedServerInnerHTML === unwrappedClientInnerHTML) {
7717
+ if (isSanitizedHtmlContentEqual(getProperty(elm, 'innerHTML'), props.innerHTML)) {
7816
7718
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
7817
7719
  vnode.data = {
7818
7720
  ...vnode.data,
7819
7721
  props: cloneAndOmitKey(props, 'innerHTML'),
7820
7722
  };
7821
7723
  }
7822
- else if (process.env.NODE_ENV !== 'production') {
7823
- queueHydrationError('innerHTML', unwrappedServerInnerHTML, unwrappedClientInnerHTML);
7724
+ else {
7725
+ if (process.env.NODE_ENV !== 'production') {
7726
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
7727
+ }
7824
7728
  }
7825
7729
  }
7826
7730
  }
@@ -7843,7 +7747,8 @@ function hydrateCustomElement(elm, vnode, renderer) {
7843
7747
  //
7844
7748
  // Therefore, if validationOptOut is falsey or an array of strings, we need to
7845
7749
  // examine some or all of the custom element's attributes.
7846
- if (!isTypeElement(elm) || !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
7750
+ if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
7751
+ !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
7847
7752
  return handleMismatch(elm, vnode, renderer);
7848
7753
  }
7849
7754
  const { sel, mode, ctor, owner } = vnode;
@@ -7879,13 +7784,9 @@ function hydrateChildren(node, children, parentNode, owner,
7879
7784
  // last node of the fragment. Hydration should not fail if a trailing sibling is
7880
7785
  // found in this case.
7881
7786
  expectAddlSiblings) {
7882
- let mismatchedChildren = false;
7787
+ let hasWarned = false;
7883
7788
  let nextNode = node;
7884
7789
  const { renderer } = owner;
7885
- const { getChildNodes, cloneNode } = renderer;
7886
- const serverNodes = process.env.NODE_ENV !== 'production'
7887
- ? Array.from(getChildNodes(parentNode), (node) => cloneNode(node, true))
7888
- : null;
7889
7790
  for (let i = 0; i < children.length; i++) {
7890
7791
  const childVnode = children[i];
7891
7792
  if (!shared.isNull(childVnode)) {
@@ -7893,7 +7794,13 @@ expectAddlSiblings) {
7893
7794
  nextNode = hydrateNode(nextNode, childVnode, renderer);
7894
7795
  }
7895
7796
  else {
7896
- mismatchedChildren = true;
7797
+ hasMismatch = true;
7798
+ if (process.env.NODE_ENV !== 'production') {
7799
+ if (!hasWarned) {
7800
+ hasWarned = true;
7801
+ logWarn(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
7802
+ }
7803
+ }
7897
7804
  mount(childVnode, parentNode, renderer, nextNode);
7898
7805
  nextNode = renderer.nextSibling(childVnode.type === 5 /* VNodeType.Fragment */ ? childVnode.trailing : childVnode.elm);
7899
7806
  }
@@ -7910,7 +7817,12 @@ expectAddlSiblings) {
7910
7817
  // rendered more nodes than the client.
7911
7818
  (!useCommentsForBookends || !expectAddlSiblings) &&
7912
7819
  nextNode) {
7913
- mismatchedChildren = true;
7820
+ hasMismatch = true;
7821
+ if (process.env.NODE_ENV !== 'production') {
7822
+ if (!hasWarned) {
7823
+ logWarn(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
7824
+ }
7825
+ }
7914
7826
  // nextSibling is mostly harmless, and since we don't have
7915
7827
  // a good reference to what element to act upon, we instead
7916
7828
  // rely on the vm's associated renderer for navigating to the
@@ -7922,14 +7834,6 @@ expectAddlSiblings) {
7922
7834
  removeNode(current, parentNode, renderer);
7923
7835
  } while (nextNode);
7924
7836
  }
7925
- if (mismatchedChildren) {
7926
- hasMismatch = true;
7927
- // We can't know exactly which node(s) caused the delta, but we can provide context (parent) and the mismatched sets
7928
- if (process.env.NODE_ENV !== 'production') {
7929
- const clientNodes = shared.ArrayMap.call(children, (c) => c?.elm);
7930
- queueHydrationError('child node', serverNodes, clientNodes);
7931
- }
7932
- }
7933
7837
  }
7934
7838
  function handleMismatch(node, vnode, renderer) {
7935
7839
  hasMismatch = true;
@@ -7945,21 +7849,31 @@ function patchElementPropsAndAttrsAndRefs(vnode, renderer) {
7945
7849
  // The `refs` object is blown away in every re-render, so we always need to re-apply them
7946
7850
  applyRefs(vnode, vnode.owner);
7947
7851
  }
7852
+ function hasCorrectNodeType(vnode, node, nodeType, renderer) {
7853
+ const { getProperty } = renderer;
7854
+ if (getProperty(node, 'nodeType') !== nodeType) {
7855
+ if (process.env.NODE_ENV !== 'production') {
7856
+ logWarn('Hydration mismatch: incorrect node type received', vnode.owner);
7857
+ }
7858
+ return false;
7859
+ }
7860
+ return true;
7861
+ }
7948
7862
  function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
7949
7863
  const { getProperty } = renderer;
7950
7864
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
7951
7865
  if (process.env.NODE_ENV !== 'production') {
7952
- queueHydrationError('node', elm);
7866
+ logWarn(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
7953
7867
  }
7954
7868
  return false;
7955
7869
  }
7956
7870
  const { data } = vnode;
7957
- const hasCompatibleAttrs = validateAttrs(elm, data, renderer, shouldValidateAttr);
7871
+ const hasCompatibleAttrs = validateAttrs(vnode, elm, data, renderer, shouldValidateAttr);
7958
7872
  const hasCompatibleClass = shouldValidateAttr('class')
7959
7873
  ? validateClassAttr(vnode, elm, data, renderer)
7960
7874
  : true;
7961
7875
  const hasCompatibleStyle = shouldValidateAttr('style')
7962
- ? validateStyleAttr(elm, data, renderer)
7876
+ ? validateStyleAttr(vnode, elm, data, renderer)
7963
7877
  : true;
7964
7878
  return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
7965
7879
  }
@@ -7976,7 +7890,7 @@ function attributeValuesAreEqual(vnodeValue, value) {
7976
7890
  // In all other cases, the two values are not considered equal
7977
7891
  return false;
7978
7892
  }
7979
- function validateAttrs(elm, data, renderer, shouldValidateAttr) {
7893
+ function validateAttrs(vnode, elm, data, renderer, shouldValidateAttr) {
7980
7894
  const { attrs = {} } = data;
7981
7895
  let nodesAreCompatible = true;
7982
7896
  // Validate attributes, though we could always recovery from those by running the update mods.
@@ -7989,7 +7903,8 @@ function validateAttrs(elm, data, renderer, shouldValidateAttr) {
7989
7903
  const elmAttrValue = getAttribute(elm, attrName);
7990
7904
  if (!attributeValuesAreEqual(attrValue, elmAttrValue)) {
7991
7905
  if (process.env.NODE_ENV !== 'production') {
7992
- queueHydrationError('attribute', prettyPrintAttribute(attrName, elmAttrValue), prettyPrintAttribute(attrName, attrValue));
7906
+ const { getProperty } = renderer;
7907
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found ${shared.isNull(elmAttrValue) ? 'null' : `"${elmAttrValue}"`}`, vnode.owner);
7993
7908
  }
7994
7909
  nodesAreCompatible = false;
7995
7910
  }
@@ -8017,6 +7932,7 @@ function validateClassAttr(vnode, elm, data, renderer) {
8017
7932
  // classMap is never available on VStaticPartData so it can default to undefined
8018
7933
  // casting to prevent TS error.
8019
7934
  const { className, classMap } = data;
7935
+ const { getProperty } = renderer;
8020
7936
  // ---------- Step 1: get the classes from the element and the vnode
8021
7937
  // Use a Set because we don't care to validate mismatches for 1) different ordering in SSR vs CSR, or 2)
8022
7938
  // duplicated class names. These don't have an effect on rendered styles.
@@ -8062,11 +7978,12 @@ function validateClassAttr(vnode, elm, data, renderer) {
8062
7978
  // ---------- Step 3: check for compatibility
8063
7979
  const classesAreCompatible = checkClassesCompatibility(vnodeClasses, elmClasses);
8064
7980
  if (process.env.NODE_ENV !== 'production' && !classesAreCompatible) {
8065
- queueHydrationError('attribute', prettyPrintClasses(elmClasses), prettyPrintClasses(vnodeClasses));
7981
+ const prettyPrint = (set) => JSON.stringify(shared.ArrayJoin.call(shared.ArraySort.call(shared.ArrayFrom(set)), ' '));
7982
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${prettyPrint(vnodeClasses)} but found ${prettyPrint(elmClasses)}`, vnode.owner);
8066
7983
  }
8067
7984
  return classesAreCompatible;
8068
7985
  }
8069
- function validateStyleAttr(elm, data, renderer) {
7986
+ function validateStyleAttr(vnode, elm, data, renderer) {
8070
7987
  // Note styleDecls is always undefined for VStaticPartData, casting here to default it to undefined
8071
7988
  const { style, styleDecls } = data;
8072
7989
  const { getAttribute } = renderer;
@@ -8100,33 +8017,49 @@ function validateStyleAttr(elm, data, renderer) {
8100
8017
  }
8101
8018
  vnodeStyle = shared.ArrayJoin.call(expectedStyle, ' ');
8102
8019
  }
8103
- if (process.env.NODE_ENV !== 'production' && !nodesAreCompatible) {
8104
- queueHydrationError('attribute', prettyPrintAttribute('style', elmStyle), prettyPrintAttribute('style', vnodeStyle));
8020
+ if (!nodesAreCompatible) {
8021
+ if (process.env.NODE_ENV !== 'production') {
8022
+ const { getProperty } = renderer;
8023
+ logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
8024
+ }
8105
8025
  }
8106
8026
  return nodesAreCompatible;
8107
8027
  }
8108
- function areStaticElementsCompatible(clientElement, serverElement, vnode, renderer) {
8028
+ function areCompatibleStaticNodes(client, ssr, vnode, renderer) {
8109
8029
  const { getProperty, getAttribute } = renderer;
8110
- const { parts } = vnode;
8030
+ if (getProperty(client, 'nodeType') === 3 /* EnvNodeTypes.TEXT */) {
8031
+ if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
8032
+ return false;
8033
+ }
8034
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
8035
+ }
8036
+ if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
8037
+ if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
8038
+ return false;
8039
+ }
8040
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
8041
+ }
8042
+ if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
8043
+ return false;
8044
+ }
8045
+ const { owner, parts } = vnode;
8111
8046
  let isCompatibleElements = true;
8112
- if (getProperty(clientElement, 'tagName') !== getProperty(serverElement, 'tagName')) {
8047
+ if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
8113
8048
  if (process.env.NODE_ENV !== 'production') {
8114
- queueHydrationError('node', serverElement);
8049
+ logWarn(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, owner);
8115
8050
  }
8116
8051
  return false;
8117
8052
  }
8118
- const clientAttrsNames = getProperty(clientElement, 'getAttributeNames').call(clientElement);
8053
+ const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
8119
8054
  clientAttrsNames.forEach((attrName) => {
8120
- const clientAttributeValue = getAttribute(clientElement, attrName);
8121
- const serverAttributeValue = getAttribute(serverElement, attrName);
8122
- if (clientAttributeValue !== serverAttributeValue) {
8055
+ if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
8123
8056
  // Check if the root element attributes have expressions, if it does then we need to delegate hydration
8124
8057
  // validation to haveCompatibleStaticParts.
8125
8058
  // Note if there are no parts then it is a fully static fragment.
8126
8059
  // partId === 0 will always refer to the root element, this is guaranteed by the compiler.
8127
8060
  if (parts?.[0].partId !== 0) {
8128
8061
  if (process.env.NODE_ENV !== 'production') {
8129
- queueHydrationError('attribute', prettyPrintAttribute(attrName, serverAttributeValue), prettyPrintAttribute(attrName, clientAttributeValue));
8062
+ logWarn(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, owner);
8130
8063
  }
8131
8064
  isCompatibleElements = false;
8132
8065
  }
@@ -8135,7 +8068,7 @@ function areStaticElementsCompatible(clientElement, serverElement, vnode, render
8135
8068
  return isCompatibleElements;
8136
8069
  }
8137
8070
  function haveCompatibleStaticParts(vnode, renderer) {
8138
- const { parts } = vnode;
8071
+ const { parts, owner } = vnode;
8139
8072
  if (shared.isUndefined(parts)) {
8140
8073
  return true;
8141
8074
  }
@@ -8146,11 +8079,11 @@ function haveCompatibleStaticParts(vnode, renderer) {
8146
8079
  for (const part of parts) {
8147
8080
  const { elm } = part;
8148
8081
  if (isVStaticPartElement(part)) {
8149
- if (!isTypeElement(elm)) {
8082
+ if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
8150
8083
  return false;
8151
8084
  }
8152
8085
  const { data } = part;
8153
- const hasMatchingAttrs = validateAttrs(elm, data, renderer, () => true);
8086
+ const hasMatchingAttrs = validateAttrs(vnode, elm, data, renderer, () => true);
8154
8087
  // Explicitly skip hydration validation when static parts don't contain `style` or `className`.
8155
8088
  // This means the style/class attributes are either static or don't exist on the element and
8156
8089
  // cannot be affected by hydration.
@@ -8160,7 +8093,7 @@ function haveCompatibleStaticParts(vnode, renderer) {
8160
8093
  ? validateClassAttr(vnode, elm, data, renderer)
8161
8094
  : true;
8162
8095
  const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
8163
- ? validateStyleAttr(elm, data, renderer)
8096
+ ? validateStyleAttr(vnode, elm, data, renderer)
8164
8097
  : true;
8165
8098
  if (shared.isFalse(hasMatchingAttrs && hasMatchingClass && hasMatchingStyleAttr)) {
8166
8099
  return false;
@@ -8168,10 +8101,10 @@ function haveCompatibleStaticParts(vnode, renderer) {
8168
8101
  }
8169
8102
  else {
8170
8103
  // VStaticPartText
8171
- if (!isTypeText(elm)) {
8104
+ if (!hasCorrectNodeType(vnode, elm, 3 /* EnvNodeTypes.TEXT */, renderer)) {
8172
8105
  return false;
8173
8106
  }
8174
- updateTextContent(elm, part, renderer);
8107
+ updateTextContent(elm, part, owner, renderer);
8175
8108
  }
8176
8109
  }
8177
8110
  return true;
@@ -8488,5 +8421,5 @@ exports.swapTemplate = swapTemplate;
8488
8421
  exports.track = track;
8489
8422
  exports.unwrap = unwrap;
8490
8423
  exports.wire = wire;
8491
- /** version: 8.12.6 */
8424
+ /** version: 8.12.2 */
8492
8425
  //# sourceMappingURL=index.cjs.js.map