@lwrjs/everywhere 0.17.2-alpha.1 → 0.17.2-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/b994db565f626754886e7e67558cf02e/config.js +12 -0
  2. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/s/3aba11034f11c8d5598c93bfca4d4690/@lwrjs_app-service_amd-bootstrap_module_amd.js +5 -5
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{8_12_1/s/418c7a7bff7c2d0c999a904a19d22f33 → 8_12_6/s/386f673e62a516d2ee3206eeaaacfd2f}/lwc.js +293 -167
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js +3 -3
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_17_2-alpha_1/s/d7186d4fbbc58762dab0d51cc1f0afb8 → 0_17_2-alpha_3/s/6451a6239fe9143b9edff08eb9b3698f}/lwr_init.js +42 -22
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_17_2-alpha_1/s/dab49010308c4d6962f114684f8edf03 → 0_17_2-alpha_3/s/746749c2fd6d0d429f6a185177cd8749}/lwr_loader.js +3 -3
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/s/fb8c5dd340c69fdf7ded52d3eba633b9/lwr_metrics.js +1 -1
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/s/ec0fad0e38a96bb0b88c9f4553460347/lwr_preInit.js +1 -1
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +1 -1
  10. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
  11. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/lwr-error-shim.js +1 -1
  12. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_17_2-alpha_1 → 0_17_2-alpha_3}/lwr-loader-shim.bundle.js +6 -6
  13. package/build/assets/amd/lwr-everywhere-debug.js +8 -8
  14. package/build/assets/amd/lwr-everywhere-min.js +2 -2
  15. package/build/assets/amd/lwr-everywhere.js +8 -8
  16. package/build/assets/core/lwr-everywhere-debug.js +4 -4
  17. package/build/assets/core/lwr-everywhere.js +4 -4
  18. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  19. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  20. package/build/assets/esm/lwr-everywhere.js +1 -1
  21. package/package.json +6 -6
  22. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/dc1d50eac65566131ac5de28d911a743/config.js +0 -12
@@ -1,10 +1,10 @@
1
- LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwc/v/8_12_6', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /**
4
- * Copyright (c) 2024 Salesforce, Inc.
4
+ * Copyright (c) 2025 Salesforce, Inc.
5
5
  */
6
6
  /**
7
- * Copyright (c) 2024 Salesforce, Inc.
7
+ * Copyright (c) 2025 Salesforce, Inc.
8
8
  */
9
9
  /*
10
10
  * Copyright (c) 2018, salesforce.com, inc.
@@ -398,6 +398,11 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
398
398
  const CAMEL_REGEX = /-([a-z])/g;
399
399
  // These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
400
400
  const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/new Map([['accessKey', 'accesskey'], ['readOnly', 'readonly'], ['tabIndex', 'tabindex'], ['bgColor', 'bgcolor'], ['colSpan', 'colspan'], ['rowSpan', 'rowspan'], ['contentEditable', 'contenteditable'], ['crossOrigin', 'crossorigin'], ['dateTime', 'datetime'], ['formAction', 'formaction'], ['isMap', 'ismap'], ['maxLength', 'maxlength'], ['minLength', 'minlength'], ['noValidate', 'novalidate'], ['useMap', 'usemap'], ['htmlFor', 'for']]);
401
+ // Global properties that this framework currently reflects. For CSR, the native
402
+ // descriptors for these properties are added from HTMLElement.prototype to
403
+ // LightningElement.prototype. For SSR, in order to match CSR behavior, this
404
+ // list is used to determine which attributes to reflect.
405
+ const REFLECTIVE_GLOBAL_PROPERTY_SET = /*@__PURE__@*/new Set(['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title']);
401
406
  /**
402
407
  * Map associating previously transformed HTML property into HTML attribute.
403
408
  */
@@ -458,7 +463,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
458
463
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
459
464
  */
460
465
  // Increment whenever the LWC template compiler changes
461
- const LWC_VERSION = "8.12.1";
466
+ const LWC_VERSION = "8.12.6";
462
467
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
463
468
 
464
469
  /*
@@ -576,10 +581,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
576
581
  }
577
582
  return trustedSignals.has(target);
578
583
  }
579
- /** version: 8.12.1 */
584
+ /** version: 8.12.6 */
580
585
 
581
586
  /**
582
- * Copyright (c) 2024 Salesforce, Inc.
587
+ * Copyright (c) 2025 Salesforce, Inc.
583
588
  */
584
589
 
585
590
  /*
@@ -600,7 +605,8 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
600
605
  ENABLE_LEGACY_SCOPE_TOKENS: null,
601
606
  ENABLE_FORCE_SHADOW_MIGRATE_MODE: null,
602
607
  ENABLE_EXPERIMENTAL_SIGNALS: null,
603
- DISABLE_SYNTHETIC_SHADOW: null
608
+ DISABLE_SYNTHETIC_SHADOW: null,
609
+ LEGACY_LOCKER_ENABLED: null
604
610
  };
605
611
  if (!globalThis.lwcRuntimeFlags) {
606
612
  Object.defineProperty(globalThis, 'lwcRuntimeFlags', {
@@ -663,10 +669,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
663
669
  setFeatureFlag(name, value);
664
670
  }
665
671
  }
666
- /** version: 8.12.1 */
672
+ /** version: 8.12.6 */
667
673
 
668
674
  /**
669
- * Copyright (c) 2024 Salesforce, Inc.
675
+ * Copyright (c) 2025 Salesforce, Inc.
670
676
  */
671
677
 
672
678
  /*
@@ -905,6 +911,15 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
905
911
  }
906
912
  return ctorFormAssociated && apiFeatureEnabled;
907
913
  }
914
+ // check if a property is in an object, and if the object throws an error merely because we are
915
+ // checking if the property exists, return false
916
+ function safeHasProp(obj, prop) {
917
+ try {
918
+ return prop in obj;
919
+ } catch (_err) {
920
+ return false;
921
+ }
922
+ }
908
923
 
909
924
  /*
910
925
  * Copyright (c) 2024, Salesforce, Inc.
@@ -1228,10 +1243,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1228
1243
  valueObserved(component, key);
1229
1244
  }
1230
1245
  // The portion of reactivity that's exposed to signals is to subscribe a callback to re-render the VM (templates).
1231
- // We check check the following to ensure re-render is subscribed at the correct time.
1246
+ // We check the following to ensure re-render is subscribed at the correct time.
1232
1247
  // 1. The template is currently being rendered (there is a template reactive observer)
1233
1248
  // 2. There was a call to a getter to access the signal (happens during vnode generation)
1234
- if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS && isObject(target) && !isNull(target) && 'value' in target && 'subscribe' in target && isFunction$1(target.subscribe) && isTrustedSignal(target) &&
1249
+ if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS && isObject(target) && !isNull(target) && safeHasProp(target, 'value') && safeHasProp(target, 'subscribe') && isFunction$1(target.subscribe) && isTrustedSignal(target) &&
1235
1250
  // Only subscribe if a template is being rendered by the engine
1236
1251
  tro.isObserving()) {
1237
1252
  // Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
@@ -1317,15 +1332,6 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1317
1332
  // Add descriptors for ARIA attributes
1318
1333
  for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {}
1319
1334
 
1320
- /*
1321
- * Copyright (c) 2018, salesforce.com, inc.
1322
- * All rights reserved.
1323
- * SPDX-License-Identifier: MIT
1324
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1325
- */
1326
- // These properties get added to LWCElement.prototype publicProps automatically
1327
- const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1328
-
1329
1335
  /*
1330
1336
  * Copyright (c) 2018, salesforce.com, inc.
1331
1337
  * All rights reserved.
@@ -1347,7 +1353,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1347
1353
  HTMLElementOriginalDescriptors[propName] = descriptor;
1348
1354
  }
1349
1355
  });
1350
- forEach.call(defaultDefHTMLPropertyNames, propName => {
1356
+ for (const propName of REFLECTIVE_GLOBAL_PROPERTY_SET) {
1351
1357
  // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1352
1358
  // in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
1353
1359
  // this category, so, better to be sure.
@@ -1355,7 +1361,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1355
1361
  if (!isUndefined$1(descriptor)) {
1356
1362
  HTMLElementOriginalDescriptors[propName] = descriptor;
1357
1363
  }
1358
- });
1364
+ }
1359
1365
 
1360
1366
  /*
1361
1367
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1942,7 +1948,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1942
1948
  valueMutated(originalTarget, key);
1943
1949
  return true;
1944
1950
  }
1945
- /*LWC compiler v8.12.1*/
1951
+ /*LWC compiler v8.12.6*/
1946
1952
  }
1947
1953
  const getterMap = new WeakMap();
1948
1954
  const setterMap = new WeakMap();
@@ -1989,7 +1995,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
1989
1995
  /* istanbul ignore next */
1990
1996
  return false;
1991
1997
  }
1992
- /*LWC compiler v8.12.1*/
1998
+ /*LWC compiler v8.12.6*/
1993
1999
  }
1994
2000
  function defaultValueIsObservable(value) {
1995
2001
  // intentionally checking for null
@@ -3681,7 +3687,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
3681
3687
  }
3682
3688
  function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
3683
3689
  const HTMLBridgeElement = class extends SuperClass {
3684
- /*LWC compiler v8.12.1*/
3690
+ /*LWC compiler v8.12.6*/
3685
3691
  };
3686
3692
  // generating the hash table for attributes to avoid duplicate fields and facilitate validation
3687
3693
  // and false positives in case of inheritance.
@@ -3694,7 +3700,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
3694
3700
  } = SuperClass;
3695
3701
  const descriptors = create(null);
3696
3702
  // present a hint message so that developers are aware that they have not decorated property with @api
3697
- if (process.env.NODE_ENV !== 'production') {
3703
+ // Note that we also don't do this in SSR because we cannot sniff for what props are declared on
3704
+ // HTMLElementPrototype, and it seems not worth it to have these dev-only warnings there, since
3705
+ // an `in` check could mistakenly assume that a prop is declared on a LightningElement prototype.
3706
+ if (process.env.NODE_ENV !== 'production' && true) {
3698
3707
  // TODO [#3761]: enable for components that don't extend from LightningElement
3699
3708
  if (!isUndefined$1(proto) && !isNull(proto) && !hasCustomSuperClass) {
3700
3709
  const nonPublicPropertiesToWarnOn = new Set([
@@ -4736,15 +4745,6 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
4736
4745
  setProperty(elm, key, value);
4737
4746
  }
4738
4747
  }
4739
- /**
4740
- * Given two objects (likely either a string or a SanitizedHtmlContent object), return true if their
4741
- * string values are equivalent.
4742
- * @param first
4743
- * @param second
4744
- */
4745
- function isSanitizedHtmlContentEqual(first, second) {
4746
- return unwrapIfNecessary(first) === unwrapIfNecessary(second);
4747
- }
4748
4748
 
4749
4749
  /*
4750
4750
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6706,7 +6706,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
6706
6706
  * SPDX-License-Identifier: MIT
6707
6707
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6708
6708
  */
6709
- const operationIdNameMapping = ['constructor', 'render', 'patch', 'connectedCallback', 'renderedCallback', 'disconnectedCallback', 'errorCallback', 'lwc-hydrate', 'lwc-rehydrate'];
6709
+ const operationIdNameMapping = ['constructor', 'render', 'patch', 'connectedCallback', 'renderedCallback', 'disconnectedCallback', 'errorCallback', 'lwc-render', 'lwc-rerender', 'lwc-ssr-hydrate'];
6710
6710
  const operationTooltipMapping = [
6711
6711
  // constructor
6712
6712
  'component constructor()',
@@ -6722,10 +6722,12 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
6722
6722
  'component disconnectedCallback()',
6723
6723
  // errorCallback
6724
6724
  'component errorCallback()',
6725
- // lwc-hydrate
6725
+ // lwc-render
6726
6726
  'component first rendered',
6727
- // lwc-rehydrate
6728
- 'component re-rendered'];
6727
+ // lwc-rerender
6728
+ 'component re-rendered',
6729
+ // lwc-ssr-hydrate
6730
+ 'component hydrated from server-rendered HTML'];
6729
6731
  // Even if all the browser the engine supports implements the UserTiming API, we need to guard the measure APIs.
6730
6732
  // JSDom (used in Jest) for example doesn't implement the UserTiming APIs.
6731
6733
  const isUserTimingSupported = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
@@ -6765,13 +6767,14 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
6765
6767
  function getColor(opId) {
6766
6768
  // As of Sept 2024: primary (dark blue), secondary (light blue), tertiary (green)
6767
6769
  switch (opId) {
6768
- // GlobalHydrate and Constructor tend to occur at the top level
6769
- case 7 /* OperationId.GlobalHydrate */:
6770
+ // GlobalSsrHydrate, GlobalRender, and Constructor tend to occur at the top level
6771
+ case 7 /* OperationId.GlobalRender */:
6772
+ case 9 /* OperationId.GlobalSsrHydrate */:
6770
6773
  case 0 /* OperationId.Constructor */:
6771
6774
  return 'primary';
6772
- // GlobalRehydrate also occurs at the top level, but we want to use tertiary (green) because it's easier to
6775
+ // GlobalRerender also occurs at the top level, but we want to use tertiary (green) because it's easier to
6773
6776
  // distinguish from primary, and at a glance you should be able to easily tell re-renders from first renders.
6774
- case 8 /* OperationId.GlobalRehydrate */:
6777
+ case 8 /* OperationId.GlobalRerender */:
6775
6778
  return 'tertiary';
6776
6779
  // Everything else (patch/render/callbacks)
6777
6780
  default:
@@ -6977,7 +6980,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
6977
6980
  function setVMBeingRendered(vm) {
6978
6981
  vmBeingRendered = vm;
6979
6982
  }
6980
- const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_.]+$/;
6983
+ const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_]+$/;
6981
6984
  // See W-16614556
6982
6985
  // TODO [#2826]: freeze the template object
6983
6986
  function isValidScopeToken(token) {
@@ -7287,7 +7290,8 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
7287
7290
  // the "instanceof" operator would not work here since Locker Service provides its own
7288
7291
  // implementation of LightningElement, so we indirectly check if the base constructor is
7289
7292
  // invoked by accessing the component on the vm.
7290
- if (vmBeingConstructed.component !== result) {
7293
+ const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED ? vmBeingConstructed.component !== result : !(result instanceof LightningElement);
7294
+ if (isInvalidConstructor) {
7291
7295
  throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
7292
7296
  }
7293
7297
  } catch (e) {
@@ -7486,10 +7490,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
7486
7490
  const vm = getAssociatedVM(elm);
7487
7491
  if (process.env.NODE_ENV !== 'production') {
7488
7492
  // Flush any logs for this VM so that the initial properties from the constructor don't "count"
7489
- // in subsequent re-renders (lwc-rehydrate). Right now we're at the first render (lwc-hydrate).
7493
+ // in subsequent re-renders (lwc-rerender). Right now we're at the first render (lwc-hydrate).
7490
7494
  flushMutationLogsForVM(vm);
7491
7495
  }
7492
- logGlobalOperationStartWithVM(7 /* OperationId.GlobalHydrate */, vm);
7496
+ logGlobalOperationStartWithVM(7 /* OperationId.GlobalRender */, vm);
7493
7497
  // Usually means moving the element from one place to another, which is observable via
7494
7498
  // life-cycle hooks.
7495
7499
  if (vm.state === 1 /* VMState.connected */) {
@@ -7497,7 +7501,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
7497
7501
  }
7498
7502
  runConnectedCallback(vm);
7499
7503
  rehydrate(vm);
7500
- logGlobalOperationEndWithVM(7 /* OperationId.GlobalHydrate */, vm);
7504
+ logGlobalOperationEndWithVM(7 /* OperationId.GlobalRender */, vm);
7501
7505
  }
7502
7506
  function disconnectRootElement(elm) {
7503
7507
  const vm = getAssociatedVM(elm);
@@ -7821,7 +7825,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
7821
7825
  // Gather the logs before rehydration starts so they can be reported at the end of rehydration.
7822
7826
  // Note that we also clear all existing logs at this point so that subsequent re-renders start from a clean slate.
7823
7827
  const mutationLogs = process.env.NODE_ENV === 'production' ? undefined : getAndFlushMutationLogs();
7824
- logGlobalOperationStart(8 /* OperationId.GlobalRehydrate */);
7828
+ logGlobalOperationStart(8 /* OperationId.GlobalRerender */);
7825
7829
  if (process.env.NODE_ENV !== 'production') {
7826
7830
  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}.`);
7827
7831
  }
@@ -7840,13 +7844,13 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
7840
7844
  ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
7841
7845
  }
7842
7846
  // we need to end the measure before throwing.
7843
- logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */, mutationLogs);
7847
+ logGlobalOperationEnd(8 /* OperationId.GlobalRerender */, mutationLogs);
7844
7848
  // re-throwing the original error will break the current tick, but since the next tick is
7845
7849
  // already scheduled, it should continue patching the rest.
7846
7850
  throw error;
7847
7851
  }
7848
7852
  }
7849
- logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */, mutationLogs);
7853
+ logGlobalOperationEnd(8 /* OperationId.GlobalRerender */, mutationLogs);
7850
7854
  }
7851
7855
  function runConnectedCallback(vm) {
7852
7856
  const {
@@ -8376,6 +8380,82 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8376
8380
  }
8377
8381
  }
8378
8382
 
8383
+ /*
8384
+ * Copyright (c) 2024, Salesforce, Inc.
8385
+ * All rights reserved.
8386
+ * SPDX-License-Identifier: MIT
8387
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8388
+ */
8389
+ // Errors that occured during the hydration process
8390
+ let hydrationErrors = [];
8391
+ /*
8392
+ Prints attributes as null or "value"
8393
+ */
8394
+ function prettyPrintAttribute(attribute, value) {
8395
+ assertNotProd(); // this method should never leak to prod
8396
+ return `${attribute}=${isNull(value) || isUndefined$1(value) ? value : `"${value}"`}`;
8397
+ }
8398
+ /*
8399
+ Sorts and stringifies classes
8400
+ */
8401
+ function prettyPrintClasses(classes) {
8402
+ assertNotProd(); // this method should never leak to prod
8403
+ const value = JSON.stringify(ArrayJoin.call(ArraySort.call(ArrayFrom(classes)), ' '));
8404
+ return `class=${value}`;
8405
+ }
8406
+ /*
8407
+ Hydration errors occur before the source node has been fully hydrated,
8408
+ queue them so they can be logged later against the mounted node.
8409
+ */
8410
+ function queueHydrationError(type, serverRendered, clientExpected) {
8411
+ assertNotProd(); // this method should never leak to prod
8412
+ ArrayPush$1.call(hydrationErrors, {
8413
+ type,
8414
+ serverRendered,
8415
+ clientExpected
8416
+ });
8417
+ }
8418
+ /*
8419
+ Flushes (logs) any queued errors after the source node has been mounted.
8420
+ */
8421
+ function flushHydrationErrors(source) {
8422
+ assertNotProd(); // this method should never leak to prod
8423
+ for (const hydrationError of hydrationErrors) {
8424
+ logHydrationWarning(`Hydration ${hydrationError.type} mismatch on:`, source, `\n- rendered on server:`, hydrationError.serverRendered, `\n- expected on client:`, hydrationError.clientExpected || source);
8425
+ }
8426
+ hydrationErrors = [];
8427
+ }
8428
+ function isTypeElement(node) {
8429
+ const isCorrectType = node?.nodeType === 1 /* EnvNodeTypes.ELEMENT */;
8430
+ if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
8431
+ queueHydrationError('node', node);
8432
+ }
8433
+ return isCorrectType;
8434
+ }
8435
+ function isTypeText(node) {
8436
+ const isCorrectType = node?.nodeType === 3 /* EnvNodeTypes.TEXT */;
8437
+ if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
8438
+ queueHydrationError('node', node);
8439
+ }
8440
+ return isCorrectType;
8441
+ }
8442
+ function isTypeComment(node) {
8443
+ const isCorrectType = node?.nodeType === 8 /* EnvNodeTypes.COMMENT */;
8444
+ if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
8445
+ queueHydrationError('node', node);
8446
+ }
8447
+ return isCorrectType;
8448
+ }
8449
+ /*
8450
+ logger.ts converts all args to a string, losing object referenences and has
8451
+ legacy bloat which would have meant more pathing.
8452
+ */
8453
+ function logHydrationWarning(...args) {
8454
+ assertNotProd(); // this method should never leak to prod
8455
+ /* eslint-disable-next-line no-console */
8456
+ console.warn('[LWC warn:', ...args);
8457
+ }
8458
+
8379
8459
  /*
8380
8460
  * Copyright (c) 2022, salesforce.com, inc.
8381
8461
  * All rights reserved.
@@ -8388,11 +8468,20 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8388
8468
  let hasMismatch = false;
8389
8469
  function hydrateRoot(vm) {
8390
8470
  hasMismatch = false;
8471
+ logGlobalOperationStartWithVM(9 /* OperationId.GlobalSsrHydrate */, vm);
8391
8472
  runConnectedCallback(vm);
8392
8473
  hydrateVM(vm);
8393
- if (hasMismatch && process.env.NODE_ENV !== 'production') {
8394
- logWarn('Hydration completed with errors.', vm);
8474
+ if (process.env.NODE_ENV !== 'production') {
8475
+ /*
8476
+ Errors are queued as they occur and then logged with the source element once it has been hydrated and mounted to the DOM.
8477
+ 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.
8478
+ */
8479
+ flushHydrationErrors(vm.renderRoot);
8480
+ if (hasMismatch) {
8481
+ logHydrationWarning('Hydration completed with errors.');
8482
+ }
8395
8483
  }
8484
+ logGlobalOperationEndWithVM(9 /* OperationId.GlobalSsrHydrate */, vm);
8396
8485
  }
8397
8486
  function hydrateVM(vm) {
8398
8487
  const children = renderComponent(vm);
@@ -8405,7 +8494,9 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8405
8494
  getFirstChild
8406
8495
  }
8407
8496
  } = vm;
8497
+ logOperationStart(2 /* OperationId.Patch */, vm);
8408
8498
  hydrateChildren(getFirstChild(parentNode), children, parentNode, vm, false);
8499
+ logOperationEnd(2 /* OperationId.Patch */, vm);
8409
8500
  runRenderedCallback(vm);
8410
8501
  }
8411
8502
  function hydrateNode(node, vnode, renderer) {
@@ -8434,23 +8525,27 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8434
8525
  hydratedNode = hydrateCustomElement(node, vnode, vnode.data.renderer ?? renderer);
8435
8526
  break;
8436
8527
  }
8528
+ if (process.env.NODE_ENV !== 'production') {
8529
+ /*
8530
+ Errors are queued as they occur and then logged with the source element once it has been hydrated and mounted to the DOM.
8531
+ 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.
8532
+ */
8533
+ flushHydrationErrors(hydratedNode);
8534
+ }
8437
8535
  return renderer.nextSibling(hydratedNode);
8438
8536
  }
8439
8537
  const NODE_VALUE_PROP = 'nodeValue';
8440
- function textNodeContentsAreEqual(node, vnode, renderer) {
8538
+ function validateTextNodeEquality(node, vnode, renderer) {
8441
8539
  const {
8442
8540
  getProperty
8443
8541
  } = renderer;
8444
8542
  const nodeValue = getProperty(node, NODE_VALUE_PROP);
8445
- if (nodeValue === vnode.text) {
8446
- return true;
8447
- }
8543
+ if (nodeValue !== vnode.text && (
8448
8544
  // Special case for empty text nodes – these are serialized differently on the server
8449
8545
  // See https://github.com/salesforce/lwc/pull/2656
8450
- if (nodeValue === '\u200D' && vnode.text === '') {
8451
- return true;
8546
+ nodeValue !== '\u200D' || vnode.text !== '')) {
8547
+ queueHydrationError('text content', nodeValue, vnode.text);
8452
8548
  }
8453
- return false;
8454
8549
  }
8455
8550
  // The validationOptOut static property can be an array of attribute names.
8456
8551
  // Any attribute names specified in that array will not be validated, and the
@@ -8468,7 +8563,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8468
8563
  const isValidArray = isArray$1(optOutStaticProp) && arrayEvery(optOutStaticProp, isString);
8469
8564
  const conditionalOptOut = isValidArray ? new Set(optOutStaticProp) : undefined;
8470
8565
  if (process.env.NODE_ENV !== 'production' && !isUndefined$1(optOutStaticProp) && !isTrue(optOutStaticProp) && !isValidArray) {
8471
- logWarn('`validationOptOut` must be `true` or an array of attributes that should not be validated.');
8566
+ logHydrationWarning('`validationOptOut` must be `true` or an array of attributes that should not be validated.');
8472
8567
  }
8473
8568
  return attrName => {
8474
8569
  // Component wants to opt out of all validation
@@ -8488,16 +8583,14 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8488
8583
  };
8489
8584
  }
8490
8585
  function hydrateText(node, vnode, renderer) {
8491
- if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
8586
+ if (!isTypeText(node)) {
8492
8587
  return handleMismatch(node, vnode, renderer);
8493
8588
  }
8494
- return updateTextContent(node, vnode, vnode.owner, renderer);
8589
+ return updateTextContent(node, vnode, renderer);
8495
8590
  }
8496
- function updateTextContent(node, vnode, owner, renderer) {
8591
+ function updateTextContent(node, vnode, renderer) {
8497
8592
  if (process.env.NODE_ENV !== 'production') {
8498
- if (!textNodeContentsAreEqual(node, vnode, renderer)) {
8499
- logWarn('Hydration mismatch: text values do not match, will recover from the difference', owner);
8500
- }
8593
+ validateTextNodeEquality(node, vnode, renderer);
8501
8594
  }
8502
8595
  const {
8503
8596
  setText
@@ -8507,7 +8600,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8507
8600
  return node;
8508
8601
  }
8509
8602
  function hydrateComment(node, vnode, renderer) {
8510
- if (!hasCorrectNodeType(vnode, node, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
8603
+ if (!isTypeComment(node)) {
8511
8604
  return handleMismatch(node, vnode, renderer);
8512
8605
  }
8513
8606
  if (process.env.NODE_ENV !== 'production') {
@@ -8516,7 +8609,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8516
8609
  } = renderer;
8517
8610
  const nodeValue = getProperty(node, NODE_VALUE_PROP);
8518
8611
  if (nodeValue !== vnode.text) {
8519
- logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
8612
+ queueHydrationError('comment', nodeValue, vnode.text);
8520
8613
  }
8521
8614
  }
8522
8615
  const {
@@ -8529,10 +8622,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8529
8622
  return node;
8530
8623
  }
8531
8624
  function hydrateStaticElement(elm, vnode, renderer) {
8532
- if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !areCompatibleStaticNodes(vnode.fragment, elm, vnode, renderer)) {
8533
- return handleMismatch(elm, vnode, renderer);
8625
+ if (isTypeElement(elm) && isTypeElement(vnode.fragment) && areStaticElementsCompatible(vnode.fragment, elm, vnode, renderer)) {
8626
+ return hydrateStaticElementParts(elm, vnode, renderer);
8534
8627
  }
8535
- return hydrateStaticElementParts(elm, vnode, renderer);
8628
+ return handleMismatch(elm, vnode, renderer);
8536
8629
  }
8537
8630
  function hydrateStaticElementParts(elm, vnode, renderer) {
8538
8631
  const {
@@ -8560,7 +8653,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8560
8653
  return vnode.elm = children[children.length - 1].elm;
8561
8654
  }
8562
8655
  function hydrateElement(elm, vnode, renderer) {
8563
- if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !isMatchingElement(vnode, elm, renderer)) {
8656
+ if (!isTypeElement(elm) || !isMatchingElement(vnode, elm, renderer)) {
8564
8657
  return handleMismatch(elm, vnode, renderer);
8565
8658
  }
8566
8659
  vnode.elm = elm;
@@ -8583,16 +8676,16 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8583
8676
  getProperty
8584
8677
  } = renderer;
8585
8678
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
8586
- if (isSanitizedHtmlContentEqual(getProperty(elm, 'innerHTML'), props.innerHTML)) {
8679
+ const unwrappedServerInnerHTML = unwrapIfNecessary(getProperty(elm, 'innerHTML'));
8680
+ const unwrappedClientInnerHTML = unwrapIfNecessary(props.innerHTML);
8681
+ if (unwrappedServerInnerHTML === unwrappedClientInnerHTML) {
8587
8682
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
8588
8683
  vnode.data = {
8589
8684
  ...vnode.data,
8590
8685
  props: cloneAndOmitKey(props, 'innerHTML')
8591
8686
  };
8592
- } else {
8593
- if (process.env.NODE_ENV !== 'production') {
8594
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, owner);
8595
- }
8687
+ } else if (process.env.NODE_ENV !== 'production') {
8688
+ queueHydrationError('innerHTML', unwrappedServerInnerHTML, unwrappedClientInnerHTML);
8596
8689
  }
8597
8690
  }
8598
8691
  }
@@ -8619,7 +8712,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8619
8712
  //
8620
8713
  // Therefore, if validationOptOut is falsey or an array of strings, we need to
8621
8714
  // examine some or all of the custom element's attributes.
8622
- if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
8715
+ if (!isTypeElement(elm) || !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
8623
8716
  return handleMismatch(elm, vnode, renderer);
8624
8717
  }
8625
8718
  const {
@@ -8665,24 +8758,23 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8665
8758
  // last node of the fragment. Hydration should not fail if a trailing sibling is
8666
8759
  // found in this case.
8667
8760
  expectAddlSiblings) {
8668
- let hasWarned = false;
8761
+ let mismatchedChildren = false;
8669
8762
  let nextNode = node;
8670
8763
  const {
8671
8764
  renderer
8672
8765
  } = owner;
8766
+ const {
8767
+ getChildNodes,
8768
+ cloneNode
8769
+ } = renderer;
8770
+ const serverNodes = process.env.NODE_ENV !== 'production' ? Array.from(getChildNodes(parentNode), node => cloneNode(node, true)) : null;
8673
8771
  for (let i = 0; i < children.length; i++) {
8674
8772
  const childVnode = children[i];
8675
8773
  if (!isNull(childVnode)) {
8676
8774
  if (nextNode) {
8677
8775
  nextNode = hydrateNode(nextNode, childVnode, renderer);
8678
8776
  } else {
8679
- hasMismatch = true;
8680
- if (process.env.NODE_ENV !== 'production') {
8681
- if (!hasWarned) {
8682
- hasWarned = true;
8683
- logWarn(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
8684
- }
8685
- }
8777
+ mismatchedChildren = true;
8686
8778
  mount(childVnode, parentNode, renderer, nextNode);
8687
8779
  nextNode = renderer.nextSibling(childVnode.type === 5 /* VNodeType.Fragment */ ? childVnode.trailing : childVnode.elm);
8688
8780
  }
@@ -8698,12 +8790,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8698
8790
  // contract. It also preserves the behavior of valid hydration failures where the server
8699
8791
  // rendered more nodes than the client.
8700
8792
  (!useCommentsForBookends || !expectAddlSiblings) && nextNode) {
8701
- hasMismatch = true;
8702
- if (process.env.NODE_ENV !== 'production') {
8703
- if (!hasWarned) {
8704
- logWarn(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
8705
- }
8706
- }
8793
+ mismatchedChildren = true;
8707
8794
  // nextSibling is mostly harmless, and since we don't have
8708
8795
  // a good reference to what element to act upon, we instead
8709
8796
  // rely on the vm's associated renderer for navigating to the
@@ -8717,6 +8804,14 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8717
8804
  removeNode(current, parentNode, renderer);
8718
8805
  } while (nextNode);
8719
8806
  }
8807
+ if (mismatchedChildren) {
8808
+ hasMismatch = true;
8809
+ // We can't know exactly which node(s) caused the delta, but we can provide context (parent) and the mismatched sets
8810
+ if (process.env.NODE_ENV !== 'production') {
8811
+ const clientNodes = ArrayMap.call(children, c => c?.elm);
8812
+ queueHydrationError('child node', serverNodes, clientNodes);
8813
+ }
8814
+ }
8720
8815
  }
8721
8816
  function handleMismatch(node, vnode, renderer) {
8722
8817
  hasMismatch = true;
@@ -8734,34 +8829,22 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8734
8829
  // The `refs` object is blown away in every re-render, so we always need to re-apply them
8735
8830
  applyRefs(vnode, vnode.owner);
8736
8831
  }
8737
- function hasCorrectNodeType(vnode, node, nodeType, renderer) {
8738
- const {
8739
- getProperty
8740
- } = renderer;
8741
- if (getProperty(node, 'nodeType') !== nodeType) {
8742
- if (process.env.NODE_ENV !== 'production') {
8743
- logWarn('Hydration mismatch: incorrect node type received', vnode.owner);
8744
- }
8745
- return false;
8746
- }
8747
- return true;
8748
- }
8749
8832
  function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
8750
8833
  const {
8751
8834
  getProperty
8752
8835
  } = renderer;
8753
8836
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
8754
8837
  if (process.env.NODE_ENV !== 'production') {
8755
- logWarn(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
8838
+ queueHydrationError('node', elm);
8756
8839
  }
8757
8840
  return false;
8758
8841
  }
8759
8842
  const {
8760
8843
  data
8761
8844
  } = vnode;
8762
- const hasCompatibleAttrs = validateAttrs(vnode, elm, data, renderer, shouldValidateAttr);
8845
+ const hasCompatibleAttrs = validateAttrs(elm, data, renderer, shouldValidateAttr);
8763
8846
  const hasCompatibleClass = shouldValidateAttr('class') ? validateClassAttr(vnode, elm, data, renderer) : true;
8764
- const hasCompatibleStyle = shouldValidateAttr('style') ? validateStyleAttr(vnode, elm, data, renderer) : true;
8847
+ const hasCompatibleStyle = shouldValidateAttr('style') ? validateStyleAttr(elm, data, renderer) : true;
8765
8848
  return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
8766
8849
  }
8767
8850
  function attributeValuesAreEqual(vnodeValue, value) {
@@ -8777,7 +8860,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8777
8860
  // In all other cases, the two values are not considered equal
8778
8861
  return false;
8779
8862
  }
8780
- function validateAttrs(vnode, elm, data, renderer, shouldValidateAttr) {
8863
+ function validateAttrs(elm, data, renderer, shouldValidateAttr) {
8781
8864
  const {
8782
8865
  attrs = {}
8783
8866
  } = data;
@@ -8794,10 +8877,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8794
8877
  const elmAttrValue = getAttribute(elm, attrName);
8795
8878
  if (!attributeValuesAreEqual(attrValue, elmAttrValue)) {
8796
8879
  if (process.env.NODE_ENV !== 'production') {
8797
- const {
8798
- getProperty
8799
- } = renderer;
8800
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found ${isNull(elmAttrValue) ? 'null' : `"${elmAttrValue}"`}`, vnode.owner);
8880
+ queueHydrationError('attribute', prettyPrintAttribute(attrName, elmAttrValue), prettyPrintAttribute(attrName, attrValue));
8801
8881
  }
8802
8882
  nodesAreCompatible = false;
8803
8883
  }
@@ -8830,9 +8910,6 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8830
8910
  className,
8831
8911
  classMap
8832
8912
  } = data;
8833
- const {
8834
- getProperty
8835
- } = renderer;
8836
8913
  // ---------- Step 1: get the classes from the element and the vnode
8837
8914
  // Use a Set because we don't care to validate mismatches for 1) different ordering in SSR vs CSR, or 2)
8838
8915
  // duplicated class names. These don't have an effect on rendered styles.
@@ -8875,12 +8952,11 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8875
8952
  // ---------- Step 3: check for compatibility
8876
8953
  const classesAreCompatible = checkClassesCompatibility(vnodeClasses, elmClasses);
8877
8954
  if (process.env.NODE_ENV !== 'production' && !classesAreCompatible) {
8878
- const prettyPrint = set => JSON.stringify(ArrayJoin.call(ArraySort.call(ArrayFrom(set)), ' '));
8879
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${prettyPrint(vnodeClasses)} but found ${prettyPrint(elmClasses)}`, vnode.owner);
8955
+ queueHydrationError('attribute', prettyPrintClasses(elmClasses), prettyPrintClasses(vnodeClasses));
8880
8956
  }
8881
8957
  return classesAreCompatible;
8882
8958
  }
8883
- function validateStyleAttr(vnode, elm, data, renderer) {
8959
+ function validateStyleAttr(elm, data, renderer) {
8884
8960
  // Note styleDecls is always undefined for VStaticPartData, casting here to default it to undefined
8885
8961
  const {
8886
8962
  style,
@@ -8916,57 +8992,38 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8916
8992
  }
8917
8993
  vnodeStyle = ArrayJoin.call(expectedStyle, ' ');
8918
8994
  }
8919
- if (!nodesAreCompatible) {
8920
- if (process.env.NODE_ENV !== 'production') {
8921
- const {
8922
- getProperty
8923
- } = renderer;
8924
- logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
8925
- }
8995
+ if (process.env.NODE_ENV !== 'production' && !nodesAreCompatible) {
8996
+ queueHydrationError('attribute', prettyPrintAttribute('style', elmStyle), prettyPrintAttribute('style', vnodeStyle));
8926
8997
  }
8927
8998
  return nodesAreCompatible;
8928
8999
  }
8929
- function areCompatibleStaticNodes(client, ssr, vnode, renderer) {
9000
+ function areStaticElementsCompatible(clientElement, serverElement, vnode, renderer) {
8930
9001
  const {
8931
9002
  getProperty,
8932
9003
  getAttribute
8933
9004
  } = renderer;
8934
- if (getProperty(client, 'nodeType') === 3 /* EnvNodeTypes.TEXT */) {
8935
- if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
8936
- return false;
8937
- }
8938
- return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
8939
- }
8940
- if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
8941
- if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
8942
- return false;
8943
- }
8944
- return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
8945
- }
8946
- if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
8947
- return false;
8948
- }
8949
9005
  const {
8950
- owner,
8951
9006
  parts
8952
9007
  } = vnode;
8953
9008
  let isCompatibleElements = true;
8954
- if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
9009
+ if (getProperty(clientElement, 'tagName') !== getProperty(serverElement, 'tagName')) {
8955
9010
  if (process.env.NODE_ENV !== 'production') {
8956
- logWarn(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, owner);
9011
+ queueHydrationError('node', serverElement);
8957
9012
  }
8958
9013
  return false;
8959
9014
  }
8960
- const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
9015
+ const clientAttrsNames = getProperty(clientElement, 'getAttributeNames').call(clientElement);
8961
9016
  clientAttrsNames.forEach(attrName => {
8962
- if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
9017
+ const clientAttributeValue = getAttribute(clientElement, attrName);
9018
+ const serverAttributeValue = getAttribute(serverElement, attrName);
9019
+ if (clientAttributeValue !== serverAttributeValue) {
8963
9020
  // Check if the root element attributes have expressions, if it does then we need to delegate hydration
8964
9021
  // validation to haveCompatibleStaticParts.
8965
9022
  // Note if there are no parts then it is a fully static fragment.
8966
9023
  // partId === 0 will always refer to the root element, this is guaranteed by the compiler.
8967
9024
  if (parts?.[0].partId !== 0) {
8968
9025
  if (process.env.NODE_ENV !== 'production') {
8969
- logWarn(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, owner);
9026
+ queueHydrationError('attribute', prettyPrintAttribute(attrName, serverAttributeValue), prettyPrintAttribute(attrName, clientAttributeValue));
8970
9027
  }
8971
9028
  isCompatibleElements = false;
8972
9029
  }
@@ -8976,8 +9033,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8976
9033
  }
8977
9034
  function haveCompatibleStaticParts(vnode, renderer) {
8978
9035
  const {
8979
- parts,
8980
- owner
9036
+ parts
8981
9037
  } = vnode;
8982
9038
  if (isUndefined$1(parts)) {
8983
9039
  return true;
@@ -8991,29 +9047,29 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
8991
9047
  elm
8992
9048
  } = part;
8993
9049
  if (isVStaticPartElement(part)) {
8994
- if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
9050
+ if (!isTypeElement(elm)) {
8995
9051
  return false;
8996
9052
  }
8997
9053
  const {
8998
9054
  data
8999
9055
  } = part;
9000
- const hasMatchingAttrs = validateAttrs(vnode, elm, data, renderer, () => true);
9056
+ const hasMatchingAttrs = validateAttrs(elm, data, renderer, () => true);
9001
9057
  // Explicitly skip hydration validation when static parts don't contain `style` or `className`.
9002
9058
  // This means the style/class attributes are either static or don't exist on the element and
9003
9059
  // cannot be affected by hydration.
9004
9060
  // We need to do class first, style second to match the ordering of non-static-optimized nodes,
9005
9061
  // otherwise the ordering of console errors is different between the two.
9006
9062
  const hasMatchingClass = shouldValidateAttr(data, 'className') ? validateClassAttr(vnode, elm, data, renderer) : true;
9007
- const hasMatchingStyleAttr = shouldValidateAttr(data, 'style') ? validateStyleAttr(vnode, elm, data, renderer) : true;
9063
+ const hasMatchingStyleAttr = shouldValidateAttr(data, 'style') ? validateStyleAttr(elm, data, renderer) : true;
9008
9064
  if (isFalse(hasMatchingAttrs && hasMatchingClass && hasMatchingStyleAttr)) {
9009
9065
  return false;
9010
9066
  }
9011
9067
  } else {
9012
9068
  // VStaticPartText
9013
- if (!hasCorrectNodeType(vnode, elm, 3 /* EnvNodeTypes.TEXT */, renderer)) {
9069
+ if (!isTypeText(elm)) {
9014
9070
  return false;
9015
9071
  }
9016
- updateTextContent(elm, part, owner, renderer);
9072
+ updateTextContent(elm, part, renderer);
9017
9073
  }
9018
9074
  }
9019
9075
  return true;
@@ -9259,7 +9315,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9259
9315
  }
9260
9316
  return getReadOnlyProxy(obj);
9261
9317
  }
9262
- /** version: 8.12.1 */
9318
+ /** version: 8.12.6 */
9263
9319
 
9264
9320
  /*
9265
9321
  * Copyright (c) 2018, salesforce.com, inc.
@@ -9553,7 +9609,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9553
9609
  formStateRestoreCallback(state, reason) {
9554
9610
  runFormStateRestoreCallback(this, state, reason);
9555
9611
  }
9556
- /*LWC compiler v8.12.1*/
9612
+ /*LWC compiler v8.12.6*/
9557
9613
  };
9558
9614
  BaseHTMLElement = HTMLElement; // cache to track if it changes
9559
9615
  }
@@ -9568,7 +9624,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9568
9624
  // Using a BaseUpgradableConstructor superclass here is a perf optimization to avoid
9569
9625
  // re-defining the same logic (connectedCallback, disconnectedCallback, etc.) over and over.
9570
9626
  class UpgradableConstructor extends BaseUpgradableConstructor {
9571
- /*LWC compiler v8.12.1*/
9627
+ /*LWC compiler v8.12.6*/
9572
9628
  }
9573
9629
  if (isFormAssociated) {
9574
9630
  // Perf optimization - the vast majority of components have formAssociated=false,
@@ -9623,7 +9679,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9623
9679
  // See `injectInlineRenderer` in /scripts/rollup/rollup.config.js
9624
9680
  const renderer = function (exports) {
9625
9681
  /**
9626
- * Copyright (c) 2024 Salesforce, Inc.
9682
+ * Copyright (c) 2025 Salesforce, Inc.
9627
9683
  */
9628
9684
  /*
9629
9685
  * Copyright (c) 2018, salesforce.com, inc.
@@ -9675,6 +9731,49 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9675
9731
  isFalse: isFalse$1,
9676
9732
  isTrue: isTrue$1
9677
9733
  });
9734
+
9735
+ /*
9736
+ * Copyright (c) 2024, Salesforce, Inc.
9737
+ * All rights reserved.
9738
+ * SPDX-License-Identifier: MIT
9739
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9740
+ */
9741
+ const {
9742
+ /** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
9743
+ assign,
9744
+ /** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
9745
+ create,
9746
+ /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
9747
+ defineProperties,
9748
+ /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
9749
+ defineProperty,
9750
+ /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
9751
+ entries,
9752
+ /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
9753
+ freeze,
9754
+ /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
9755
+ fromEntries,
9756
+ /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
9757
+ getOwnPropertyDescriptor,
9758
+ /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
9759
+ getOwnPropertyDescriptors,
9760
+ /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
9761
+ getOwnPropertyNames,
9762
+ /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
9763
+ getOwnPropertySymbols,
9764
+ /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
9765
+ getPrototypeOf,
9766
+ /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
9767
+ hasOwnProperty,
9768
+ /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
9769
+ isFrozen,
9770
+ /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
9771
+ keys,
9772
+ /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
9773
+ seal,
9774
+ /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
9775
+ setPrototypeOf
9776
+ } = Object;
9678
9777
  /**
9679
9778
  * Determines whether the argument is `undefined`.
9680
9779
  * @param obj Value to test
@@ -9691,7 +9790,18 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9691
9790
  function isNull(obj) {
9692
9791
  return obj === null;
9693
9792
  }
9694
- /** version: 8.12.1 */
9793
+ /** version: 8.12.6 */
9794
+
9795
+ /*
9796
+ * Copyright (c) 2024, Salesforce, Inc.
9797
+ * All rights reserved.
9798
+ * SPDX-License-Identifier: MIT
9799
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9800
+ */
9801
+ // Like @lwc/shared, but for DOM APIs
9802
+ const ElementDescriptors = getOwnPropertyDescriptors(Element.prototype);
9803
+ const ElementAttachShadow = ElementDescriptors.attachShadow.value;
9804
+ const ElementShadowRootGetter = ElementDescriptors.shadowRoot.get;
9695
9805
 
9696
9806
  /*
9697
9807
  * Copyright (c) 2023, salesforce.com, inc.
@@ -9711,7 +9821,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9711
9821
  this.setNewContext = setNewContext;
9712
9822
  this.setDisconnectedCallback = setDisconnectedCallback;
9713
9823
  }
9714
- /*LWC compiler v8.12.1*/
9824
+ /*LWC compiler v8.12.6*/
9715
9825
  }
9716
9826
  function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
9717
9827
  dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
@@ -9774,10 +9884,12 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
9774
9884
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
9775
9885
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
9776
9886
  // root component with customElement.define('c-app', Ctor)
9777
- if (!isNull(element.shadowRoot)) {
9778
- return element.shadowRoot;
9887
+ // see W-17441501
9888
+ const shadowRoot = ElementShadowRootGetter.call(element);
9889
+ if (!isNull(shadowRoot)) {
9890
+ return shadowRoot;
9779
9891
  }
9780
- return element.attachShadow(options);
9892
+ return ElementAttachShadow.call(element, options);
9781
9893
  }
9782
9894
  function setText(node, content) {
9783
9895
  node.nodeValue = content;
@@ -10120,7 +10232,10 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
10120
10232
  disconnectRootElement(this);
10121
10233
  }
10122
10234
  attributeChangedCallback(name, oldValue, newValue) {
10123
- attributeChangedCallback.call(this, name, oldValue, newValue);
10235
+ if (this instanceof BaseBridgeElement) {
10236
+ // W-17420330
10237
+ attributeChangedCallback.call(this, name, oldValue, newValue);
10238
+ }
10124
10239
  }
10125
10240
  formAssociatedCallback(form) {
10126
10241
  runFormAssociatedCallback(this, form);
@@ -10134,7 +10249,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
10134
10249
  formStateRestoreCallback(state, reason) {
10135
10250
  runFormStateRestoreCallback(this, state, reason);
10136
10251
  }
10137
- /*LWC compiler v8.12.1*/
10252
+ /*LWC compiler v8.12.6*/
10138
10253
  }, _a.observedAttributes = observedAttributes,
10139
10254
  // Note CustomElementConstructor is not upgraded by LWC and inherits directly from HTMLElement which means it calls the native
10140
10255
  // attachInternals API.
@@ -10343,6 +10458,17 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
10343
10458
  freeze(LightningElement);
10344
10459
  seal(LightningElement.prototype);
10345
10460
 
10461
+ /*
10462
+ * Copyright (c) 2024, Salesforce, Inc.
10463
+ * All rights reserved.
10464
+ * SPDX-License-Identifier: MIT
10465
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
10466
+ */
10467
+ // Like @lwc/shared, but for DOM APIs
10468
+ const ElementDescriptors = getOwnPropertyDescriptors(Element.prototype);
10469
+ ElementDescriptors.attachShadow.value;
10470
+ ElementDescriptors.shadowRoot.get;
10471
+
10346
10472
  /*
10347
10473
  * Copyright (c) 2018, salesforce.com, inc.
10348
10474
  * All rights reserved.
@@ -10380,7 +10506,7 @@ LWR.define('lwc/v/8_12_1', ['exports'], (function (exports) { 'use strict';
10380
10506
  });
10381
10507
  });
10382
10508
  }
10383
- /** version: 8.12.1 */
10509
+ /** version: 8.12.6 */
10384
10510
 
10385
10511
  exports.LightningElement = LightningElement;
10386
10512
  exports.__unstable__ProfilerControl = profilerControl;