@lwrjs/everywhere 0.11.0-alpha.8 → 0.11.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 (24) hide show
  1. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/cf4401d7a2e8460959bdccb3b614d8cc/config.js +11 -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_11_0/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +14 -0
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{3_2_0/s/ab8f5848cd7c307feeeb8a995ab42add → 4_0_1/s/89dbc50e02634ae47c903e8bfc5a5168}/lwc.js +739 -329
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_11_0-alpha_8 → 0_11_0}/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_11_0-alpha_8 → 0_11_0}/s/f30361ad8ff7af505bf4d465c8499181/lwr_init.js +21 -21
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_11_0-alpha_8/s/cf95c67991ad021b3047f20a4eddb7af → 0_11_0/s/6a2bfb1eac6ea32f0a60242bcbe498d0}/lwr_loader.js +6 -5
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_11_0-alpha_8 → 0_11_0}/s/274c8343f810353bbad085a79709395f/lwr_metrics.js +1 -1
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/0_11_0/s/f3a204ef43fb3057d910f80d7e9f9ba7/lwr_preInit.js +25 -0
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_11_0-alpha_8 → 0_11_0}/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +4 -7
  10. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_11_0-alpha_8 → 0_11_0}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
  11. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_11_0-alpha_8 → 0_11_0}/lwr-error-shim.js +1 -2
  12. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_11_0-alpha_8 → 0_11_0}/lwr-loader-shim.bundle.js +9 -9
  13. package/build/assets/amd/lwr-everywhere-debug.js +10 -9
  14. package/build/assets/amd/lwr-everywhere-min.js +2 -2
  15. package/build/assets/amd/lwr-everywhere.js +10 -9
  16. package/build/assets/core/lwr-everywhere-debug.js +6 -5
  17. package/build/assets/core/lwr-everywhere-min.js +1 -1
  18. package/build/assets/core/lwr-everywhere.js +6 -5
  19. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  20. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  21. package/build/assets/esm/lwr-everywhere.js +1 -1
  22. package/package.json +12 -12
  23. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/2debc576fbd7bcea1de0212c7a13c9fc/config.js +0 -11
  24. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_11_0-alpha_8/s/625ff96e920182ae7ef5b87f02964e6c/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -18
@@ -1,4 +1,4 @@
1
- LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwc/v/4_0_1', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /**
4
4
  * Copyright (C) 2023 salesforce.com, inc.
@@ -51,6 +51,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
51
51
  defineProperty,
52
52
  freeze,
53
53
  getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
54
+ getOwnPropertyDescriptors,
54
55
  getOwnPropertyNames: getOwnPropertyNames$1,
55
56
  getPrototypeOf: getPrototypeOf$1,
56
57
  hasOwnProperty: hasOwnProperty$1,
@@ -161,6 +162,28 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
161
162
  } while (o !== null);
162
163
  }
163
164
 
165
+ /*
166
+ * Copyright (c) 2023, salesforce.com, inc.
167
+ * All rights reserved.
168
+ * SPDX-License-Identifier: MIT
169
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
170
+ */
171
+ // These must be updated when the enum is updated.
172
+ // It's a bit annoying to do have to do this manually, but this makes the file tree-shakeable,
173
+ // passing the `verify-treeshakeable.js` test.
174
+ const LOWEST_API_VERSION = 58 /* APIVersion.V58_244_SUMMER_23 */;
175
+ function isAPIFeatureEnabled(apiVersionFeature, apiVersion) {
176
+ switch (apiVersionFeature) {
177
+ case 0 /* APIFeature.LOWERCASE_SCOPE_TOKENS */:
178
+ case 1 /* APIFeature.TREAT_ALL_PARSE5_ERRORS_AS_ERRORS */:
179
+ return apiVersion >= 59 /* APIVersion.V59_246_WINTER_24 */;
180
+ case 2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */:
181
+ case 3 /* APIFeature.DISABLE_OBJECT_REST_SPREAD_TRANSFORMATION */:
182
+ case 4 /* APIFeature.SKIP_UNNECESSARY_REGISTER_DECORATORS */:
183
+ return apiVersion >= 60 /* APIVersion.V60_248_SPRING_24 */;
184
+ }
185
+ }
186
+
164
187
  /*
165
188
  * Copyright (c) 2018, salesforce.com, inc.
166
189
  * All rights reserved.
@@ -291,9 +314,9 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
291
314
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
292
315
  */
293
316
  // Increment whenever the LWC template compiler changes
294
- const LWC_VERSION = "3.2.0";
317
+ const LWC_VERSION = "4.0.1";
295
318
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
296
- /** version: 3.2.0 */
319
+ /** version: 4.0.1 */
297
320
 
298
321
  /**
299
322
  * Copyright (C) 2023 salesforce.com, inc.
@@ -308,14 +331,14 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
308
331
  // When deprecating a feature flag, ensure that it is also no longer set in the application. For
309
332
  // example, in core, the flag should be removed from LwcPermAndPrefUtilImpl.java
310
333
  const features = {
311
- DUMMY_TEST_FLAG: null,
334
+ PLACEHOLDER_TEST_FLAG: null,
312
335
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
313
336
  ENABLE_MIXED_SHADOW_MODE: null,
314
337
  ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
315
338
  ENABLE_WIRE_SYNC_EMIT: null,
316
339
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
317
340
  ENABLE_FROZEN_TEMPLATE: null,
318
- DISABLE_ARIA_REFLECTION_POLYFILL: null
341
+ ENABLE_LEGACY_SCOPE_TOKENS: null
319
342
  };
320
343
  // eslint-disable-next-line no-restricted-properties
321
344
  if (!_globalThis.lwcRuntimeFlags) {
@@ -372,82 +395,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
372
395
  setFeatureFlag(name, value);
373
396
  }
374
397
  }
375
- /** version: 3.2.0 */
376
-
377
- /**
378
- * Copyright (C) 2023 salesforce.com, inc.
379
- */
380
-
381
- /*
382
- * Copyright (c) 2018, salesforce.com, inc.
383
- * All rights reserved.
384
- * SPDX-License-Identifier: MIT
385
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
386
- */
387
- function detect(propName, prototype) {
388
- return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
389
- }
390
-
391
- /*
392
- * Copyright (c) 2018, salesforce.com, inc.
393
- * All rights reserved.
394
- * SPDX-License-Identifier: MIT
395
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
396
- */
397
- function createAriaPropertyPropertyDescriptor(attrName) {
398
- // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
399
- // from Element.prototype, because these methods are overridden in LightningElement.
400
- return {
401
- get() {
402
- // reflect what's in the attribute
403
- return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
404
- },
405
- set(newValue) {
406
- // reflect into the corresponding attribute
407
- if (isNull(newValue)) {
408
- this.removeAttribute(attrName);
409
- } else {
410
- this.setAttribute(attrName, newValue);
411
- }
412
- },
413
- configurable: true,
414
- enumerable: true
415
- };
416
- }
417
- function patch$1(propName, prototype) {
418
- const attrName = AriaPropNameToAttrNameMap[propName];
419
- const descriptor = createAriaPropertyPropertyDescriptor(attrName);
420
- defineProperty(prototype, propName, descriptor);
421
- }
422
-
423
- /*
424
- * Copyright (c) 2018, salesforce.com, inc.
425
- * All rights reserved.
426
- * SPDX-License-Identifier: MIT
427
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
428
- */
429
- function applyAriaReflection(prototype = Element.prototype) {
430
- const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
431
- for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
432
- const propName = ElementPrototypeAriaPropertyNames[i];
433
- if (detect(propName, prototype)) {
434
- patch$1(propName, prototype);
435
- }
436
- }
437
- }
438
- /** version: 3.2.0 */
439
-
440
- /*
441
- * Copyright (c) 2018, salesforce.com, inc.
442
- * All rights reserved.
443
- * SPDX-License-Identifier: MIT
444
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
445
- */
446
- if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
447
- // If DISABLE_ARIA_REFLECTION_POLYFILL is false, then we need to apply the ARIA reflection polyfill globally,
448
- // i.e. to the global Element.prototype
449
- applyAriaReflection();
450
- }
398
+ /** version: 4.0.1 */
451
399
 
452
400
  /**
453
401
  * Copyright (C) 2023 salesforce.com, inc.
@@ -522,6 +470,12 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
522
470
  currentDispatcher$1(reportingEventId, payload);
523
471
  }
524
472
  }
473
+ /**
474
+ * Return true if reporting is enabled
475
+ */
476
+ function isReportingEnabled() {
477
+ return enabled$1;
478
+ }
525
479
 
526
480
  /*
527
481
  * Copyright (c) 2018, salesforce.com, inc.
@@ -816,20 +770,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
816
770
  }
817
771
  return list;
818
772
  }
819
- // Set a ref (lwc:ref) on a VM, from a template API
820
- function setRefVNode(vm, ref, vnode) {
821
- if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
822
- throw new Error('refVNodes must be defined when setting a ref');
823
- }
824
- // If this method is called, then vm.refVNodes is set as the template has refs.
825
- // If not, then something went wrong and we threw an error above.
826
- const refVNodes = vm.refVNodes;
827
- // In cases of conflict (two elements with the same ref), prefer, the last one,
828
- // in depth-first traversal order.
829
- if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
830
- refVNodes[ref] = vnode;
831
- }
832
- }
833
773
  // Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
834
774
  function assertNotProd() {
835
775
  /* istanbul ignore if */
@@ -856,6 +796,44 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
856
796
  const instrumentDef = (_a = _globalThis.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : noop;
857
797
  const instrumentInstance = (_b = _globalThis.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
858
798
 
799
+ /*
800
+ * Copyright (c) 2023, salesforce.com, inc.
801
+ * All rights reserved.
802
+ * SPDX-License-Identifier: MIT
803
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
804
+ */
805
+ // Apply ARIA string reflection behavior to a prototype.
806
+ // This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
807
+ // needed for backwards compatibility in LEX, whereas `applyAriaReflection` is designed to only apply to our own
808
+ // LightningElement/BaseBridgeElement prototypes.
809
+ function applyAriaReflection(prototype) {
810
+ for (const propName of keys(AriaPropNameToAttrNameMap)) {
811
+ const attrName = AriaPropNameToAttrNameMap[propName];
812
+ if (isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName))) {
813
+ // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
814
+ // from Element.prototype, because these methods are overridden in LightningElement.
815
+ defineProperty(prototype, propName, {
816
+ get() {
817
+ return this.getAttribute(attrName);
818
+ },
819
+ set(newValue) {
820
+ // TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
821
+ // Our historical behavior is to only treat null as removing the attribute
822
+ // See also https://github.com/w3c/aria/issues/1858
823
+ if (isNull(newValue)) {
824
+ this.removeAttribute(attrName);
825
+ } else {
826
+ this.setAttribute(attrName, newValue);
827
+ }
828
+ },
829
+ // configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
830
+ configurable: true,
831
+ enumerable: true
832
+ });
833
+ }
834
+ }
835
+ }
836
+
859
837
  /*
860
838
  * Copyright (c) 2018, salesforce.com, inc.
861
839
  * All rights reserved.
@@ -936,8 +914,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
936
914
  assertNotProd(); // this method should never leak to prod
937
915
  isDomMutationAllowed = false;
938
916
  }
939
- function logMissingPortalError(name, type) {
940
- return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
917
+ function logMissingPortalWarn(name, type) {
918
+ return logWarn(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
941
919
  }
942
920
  function patchElementWithRestrictions(elm, options) {
943
921
  assertNotProd(); // this method should never leak to prod
@@ -967,14 +945,14 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
967
945
  assign(descriptors, {
968
946
  appendChild: generateDataDescriptor({
969
947
  value(aChild) {
970
- logMissingPortalError('appendChild', 'method');
948
+ logMissingPortalWarn('appendChild', 'method');
971
949
  return appendChild.call(this, aChild);
972
950
  }
973
951
  }),
974
952
  insertBefore: generateDataDescriptor({
975
953
  value(newNode, referenceNode) {
976
954
  if (!isDomMutationAllowed) {
977
- logMissingPortalError('insertBefore', 'method');
955
+ logMissingPortalWarn('insertBefore', 'method');
978
956
  }
979
957
  return insertBefore.call(this, newNode, referenceNode);
980
958
  }
@@ -982,14 +960,14 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
982
960
  removeChild: generateDataDescriptor({
983
961
  value(aChild) {
984
962
  if (!isDomMutationAllowed) {
985
- logMissingPortalError('removeChild', 'method');
963
+ logMissingPortalWarn('removeChild', 'method');
986
964
  }
987
965
  return removeChild.call(this, aChild);
988
966
  }
989
967
  }),
990
968
  replaceChild: generateDataDescriptor({
991
969
  value(newChild, oldChild) {
992
- logMissingPortalError('replaceChild', 'method');
970
+ logMissingPortalWarn('replaceChild', 'method');
993
971
  return replaceChild.call(this, newChild, oldChild);
994
972
  }
995
973
  }),
@@ -999,7 +977,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
999
977
  },
1000
978
  set(value) {
1001
979
  if (!isDomMutationAllowed) {
1002
- logMissingPortalError('nodeValue', 'property');
980
+ logMissingPortalWarn('nodeValue', 'property');
1003
981
  }
1004
982
  originalNodeValueDescriptor.set.call(this, value);
1005
983
  }
@@ -1009,7 +987,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
1009
987
  return originalTextContentDescriptor.get.call(this);
1010
988
  },
1011
989
  set(value) {
1012
- logMissingPortalError('textContent', 'property');
990
+ logMissingPortalWarn('textContent', 'property');
1013
991
  originalTextContentDescriptor.set.call(this, value);
1014
992
  }
1015
993
  }),
@@ -1018,7 +996,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
1018
996
  return originalInnerHTMLDescriptor.get.call(this);
1019
997
  },
1020
998
  set(value) {
1021
- logMissingPortalError('innerHTML', 'property');
999
+ logMissingPortalWarn('innerHTML', 'property');
1022
1000
  return originalInnerHTMLDescriptor.set.call(this, value);
1023
1001
  }
1024
1002
  })
@@ -1527,7 +1505,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
1527
1505
  valueMutated(originalTarget, key);
1528
1506
  return true;
1529
1507
  }
1530
- /*LWC compiler v3.2.0*/
1508
+ /*LWC compiler v4.0.1*/
1531
1509
  }
1532
1510
  const getterMap = new WeakMap();
1533
1511
  const setterMap = new WeakMap();
@@ -1620,7 +1598,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
1620
1598
  /* istanbul ignore next */
1621
1599
  return false;
1622
1600
  }
1623
- /*LWC compiler v3.2.0*/
1601
+ /*LWC compiler v4.0.1*/
1624
1602
  }
1625
1603
  function extract(objectOrArray) {
1626
1604
  if (isArray(objectOrArray)) {
@@ -1987,7 +1965,68 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
1987
1965
  logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
1988
1966
  }
1989
1967
  }
1990
- const supportsElementInternals = typeof ElementInternals !== 'undefined';
1968
+ // List of properties on ElementInternals that are formAssociated can be found in the spec:
1969
+ // https://html.spec.whatwg.org/multipage/custom-elements.html#form-associated-custom-elements
1970
+ const formAssociatedProps = new Set(['setFormValue', 'form', 'setValidity', 'willValidate', 'validity', 'validationMessage', 'checkValidity', 'reportValidity', 'labels']);
1971
+ // Verify that access to a form-associated property of the ElementInternals proxy has formAssociated set in the LWC.
1972
+ function verifyPropForFormAssociation(propertyKey, isFormAssociated) {
1973
+ if (isString(propertyKey) && formAssociatedProps.has(propertyKey) && !isFormAssociated) {
1974
+ //Note this error message mirrors Chrome and Firefox error messages, in Safari the error is slightly different.
1975
+ throw new DOMException(`Failed to execute '${propertyKey}' on 'ElementInternals': The target element is not a form-associated custom element.`);
1976
+ }
1977
+ }
1978
+ const elementInternalsAccessorAllowList = new Set(['shadowRoot', 'role', ...formAssociatedProps]);
1979
+ // Prevent access to properties not defined in the HTML spec in case browsers decide to
1980
+ // provide new APIs that provide access to form associated properties.
1981
+ // This can be removed along with UpgradeableConstructor.
1982
+ function isAllowedElementInternalAccessor(propertyKey) {
1983
+ let isAllowedAccessor = false;
1984
+ // As of this writing all ElementInternal property keys as described in the spec are implemented with strings
1985
+ // in Chrome, Firefox, and Safari
1986
+ if (isString(propertyKey)) {
1987
+ // Allow list is based on HTML spec:
1988
+ // https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface
1989
+ isAllowedAccessor = elementInternalsAccessorAllowList.has(propertyKey) || /^aria/.test(propertyKey);
1990
+ if (!isAllowedAccessor && process.env.NODE_ENV !== 'production') {
1991
+ logWarn('Only properties defined in the ElementInternals HTML spec are available.');
1992
+ }
1993
+ }
1994
+ return isAllowedAccessor;
1995
+ }
1996
+ // Wrap all ElementInternal objects in a proxy to prevent form association when `formAssociated` is not set on an LWC.
1997
+ // This is needed because the 1UpgradeableConstructor1 always sets `formAssociated=true`, which means all
1998
+ // ElementInternal objects will have form-associated properties set when an LWC is placed in a form.
1999
+ // We are doing this to guard against customers taking a dependency on form elements being associated to ElementInternals
2000
+ // when 'formAssociated' has not been set on the LWC.
2001
+ function createElementInternalsProxy(elementInternals, isFormAssociated) {
2002
+ const elementInternalsProxy = new Proxy(elementInternals, {
2003
+ set(target, propertyKey, newValue) {
2004
+ if (isAllowedElementInternalAccessor(propertyKey)) {
2005
+ // Verify that formAssociated is set for form associated properties
2006
+ verifyPropForFormAssociation(propertyKey, isFormAssociated);
2007
+ return Reflect.set(target, propertyKey, newValue);
2008
+ }
2009
+ // As of this writing ElementInternals do not have non-string properties that can be set.
2010
+ return false;
2011
+ },
2012
+ get(target, propertyKey) {
2013
+ if (
2014
+ // Pass through Object.prototype methods such as toString()
2015
+ hasOwnProperty$1.call(Object.prototype, propertyKey) ||
2016
+ // As of this writing, ElementInternals only uses Symbol.toStringTag which is called
2017
+ // on Object.hasOwnProperty invocations
2018
+ Symbol.for('Symbol.toStringTag') === propertyKey ||
2019
+ // ElementInternals allow listed properties
2020
+ isAllowedElementInternalAccessor(propertyKey)) {
2021
+ // Verify that formAssociated is set for form associated properties
2022
+ verifyPropForFormAssociation(propertyKey, isFormAssociated);
2023
+ const propertyValue = Reflect.get(target, propertyKey);
2024
+ return isFunction$1(propertyValue) ? propertyValue.bind(target) : propertyValue;
2025
+ }
2026
+ }
2027
+ });
2028
+ return elementInternalsProxy;
2029
+ }
1991
2030
  // @ts-ignore
1992
2031
  LightningElement.prototype = {
1993
2032
  constructor: LightningElement,
@@ -2141,18 +2180,19 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
2141
2180
  const vm = getAssociatedVM(this);
2142
2181
  const {
2143
2182
  elm,
2183
+ def: {
2184
+ formAssociated
2185
+ },
2144
2186
  renderer: {
2145
2187
  attachInternals
2146
2188
  }
2147
2189
  } = vm;
2148
- if (isFalse(supportsElementInternals)) {
2149
- // Browsers that don't support attachInternals will need to be polyfilled before LWC is loaded.
2150
- throw new Error('attachInternals API is not supported in this browser environment.');
2151
- }
2152
- if (vm.renderMode === 0 /* RenderMode.Light */ || vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
2190
+ if (vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
2153
2191
  throw new Error('attachInternals API is not supported in light DOM or synthetic shadow.');
2154
2192
  }
2155
- return attachInternals(elm);
2193
+ const internals = attachInternals(elm);
2194
+ // #TODO[2970]: remove proxy once `UpgradeableConstructor` has been removed
2195
+ return createElementInternalsProxy(internals, Boolean(formAssociated));
2156
2196
  },
2157
2197
  get isConnected() {
2158
2198
  const vm = getAssociatedVM(this);
@@ -2349,15 +2389,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
2349
2389
  lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
2350
2390
  }
2351
2391
  defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2352
- function applyAriaReflectionToLightningElement() {
2353
- // If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
2354
- // apply it to LightningElement.prototype.
2355
- // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
2356
- applyAriaReflection(LightningElement.prototype);
2357
- }
2358
- if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
2359
- applyAriaReflectionToLightningElement();
2360
- }
2392
+ // Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
2393
+ // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
2394
+ // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
2395
+ applyAriaReflection(LightningElement.prototype);
2361
2396
  defineProperty(LightningElement, 'CustomElementConstructor', {
2362
2397
  get() {
2363
2398
  // If required, a runtime-specific implementation must be defined.
@@ -3223,9 +3258,24 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3223
3258
  this[propName] = newValue;
3224
3259
  };
3225
3260
  }
3226
- function HTMLBridgeElementFactory(SuperClass, props, methods) {
3261
+ function createAccessorThatWarns(propName) {
3262
+ let prop;
3263
+ return {
3264
+ get() {
3265
+ logWarn(`The property "${propName}" is not publicly accessible. Add the @api annotation to the property declaration or getter/setter in the component to make it accessible.`);
3266
+ return prop;
3267
+ },
3268
+ set(value) {
3269
+ logWarn(`The property "${propName}" is not publicly accessible. Add the @api annotation to the property declaration or getter/setter in the component to make it accessible.`);
3270
+ prop = value;
3271
+ },
3272
+ enumerable: true,
3273
+ configurable: true
3274
+ };
3275
+ }
3276
+ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
3227
3277
  const HTMLBridgeElement = class extends SuperClass {
3228
- /*LWC compiler v3.2.0*/
3278
+ /*LWC compiler v4.0.1*/
3229
3279
  };
3230
3280
  // generating the hash table for attributes to avoid duplicate fields and facilitate validation
3231
3281
  // and false positives in case of inheritance.
@@ -3237,9 +3287,30 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3237
3287
  observedAttributes: superObservedAttributes = []
3238
3288
  } = SuperClass;
3239
3289
  const descriptors = create(null);
3290
+ // present a hint message so that developers are aware that they have not decorated property with @api
3291
+ if (process.env.NODE_ENV !== 'production') {
3292
+ // TODO [#3761]: enable for components that don't extend from LightningElement
3293
+ if (!isUndefined$1(proto) && !isNull(proto) && !hasCustomSuperClass) {
3294
+ const nonPublicPropertiesToWarnOn = new Set([
3295
+ // getters, setters, and methods
3296
+ ...keys(getOwnPropertyDescriptors(proto)),
3297
+ // class properties
3298
+ ...observedFields]
3299
+ // we don't want to override HTMLElement props because these are meaningful in other ways,
3300
+ // and can break tooling that expects it to be iterable or defined, e.g. Jest:
3301
+ // https://github.com/jestjs/jest/blob/b4c9587/packages/pretty-format/src/plugins/DOMElement.ts#L95
3302
+ // It also doesn't make sense to override e.g. "constructor".
3303
+ .filter(propName => !(propName in HTMLElementPrototype)));
3304
+ for (const propName of nonPublicPropertiesToWarnOn) {
3305
+ if (ArrayIndexOf.call(publicProperties, propName) === -1) {
3306
+ descriptors[propName] = createAccessorThatWarns(propName);
3307
+ }
3308
+ }
3309
+ }
3310
+ }
3240
3311
  // expose getters and setters for each public props on the new Element Bridge
3241
- for (let i = 0, len = props.length; i < len; i += 1) {
3242
- const propName = props[i];
3312
+ for (let i = 0, len = publicProperties.length; i < len; i += 1) {
3313
+ const propName = publicProperties[i];
3243
3314
  attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
3244
3315
  descriptors[propName] = {
3245
3316
  get: createGetter(propName),
@@ -3266,9 +3337,26 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3266
3337
  };
3267
3338
  // To avoid leaking private component details, accessing internals from outside a component is not allowed.
3268
3339
  descriptors.attachInternals = {
3340
+ set() {
3341
+ if (process.env.NODE_ENV !== 'production') {
3342
+ logWarn('attachInternals cannot be accessed outside of a component. Use this.attachInternals instead.');
3343
+ }
3344
+ },
3345
+ get() {
3346
+ if (process.env.NODE_ENV !== 'production') {
3347
+ logWarn('attachInternals cannot be accessed outside of a component. Use this.attachInternals instead.');
3348
+ }
3349
+ }
3350
+ };
3351
+ descriptors.formAssociated = {
3352
+ set() {
3353
+ if (process.env.NODE_ENV !== 'production') {
3354
+ logWarn('formAssociated cannot be accessed outside of a component. Set the value within the component class.');
3355
+ }
3356
+ },
3269
3357
  get() {
3270
3358
  if (process.env.NODE_ENV !== 'production') {
3271
- logError('attachInternals cannot be accessed outside of a component. Use this.attachInternals instead.');
3359
+ logWarn('formAssociated cannot be accessed outside of a component. Set the value within the component class.');
3272
3360
  }
3273
3361
  }
3274
3362
  };
@@ -3282,20 +3370,20 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3282
3370
  defineProperties(HTMLBridgeElement.prototype, descriptors);
3283
3371
  return HTMLBridgeElement;
3284
3372
  }
3285
- const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
3373
+ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), [], [], null, false);
3286
3374
  {
3287
3375
  // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
3288
3376
  // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
3289
3377
  // ARIA props outside the LightningElement
3290
- if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
3291
- // If ARIA reflection is not applied globally to Element.prototype, apply it to HTMLBridgeElement.prototype.
3292
- // This allows `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*` attrs.
3293
- // This is especially important because the template compiler compiles aria-* attrs on components to aria* props
3294
- //
3295
- // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
3296
- // accessors inside the HTMLBridgeElementFactory.
3297
- applyAriaReflection(BaseBridgeElement.prototype);
3298
- }
3378
+ //
3379
+ // Apply ARIA reflection to HTMLBridgeElement.prototype. This allows `elm.aria*` property accessors to work from
3380
+ // outside a component, and to reflect `aria-*` attrs. This is especially important because the template compiler
3381
+ // compiles aria-* attrs on components to aria* props.
3382
+ // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
3383
+ //
3384
+ // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
3385
+ // accessors inside the HTMLBridgeElementFactory.
3386
+ applyAriaReflection(BaseBridgeElement.prototype);
3299
3387
  }
3300
3388
  freeze(BaseBridgeElement);
3301
3389
  seal(BaseBridgeElement.prototype);
@@ -3582,7 +3670,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3582
3670
  function createComponentDef(Ctor) {
3583
3671
  const {
3584
3672
  shadowSupportMode: ctorShadowSupportMode,
3585
- renderMode: ctorRenderMode
3673
+ renderMode: ctorRenderMode,
3674
+ formAssociated: ctorFormAssociated
3586
3675
  } = Ctor;
3587
3676
  if (process.env.NODE_ENV !== 'production') {
3588
3677
  const ctorName = Ctor.name;
@@ -3593,7 +3682,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3593
3682
  // But we keep it here just in case.
3594
3683
  logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3595
3684
  }
3596
- if (!isUndefined$1(ctorShadowSupportMode) && ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ && ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */) {
3685
+ if (!isUndefined$1(ctorShadowSupportMode) && ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ && ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */ && ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
3597
3686
  logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3598
3687
  }
3599
3688
  if (!isUndefined$1(ctorRenderMode) && ctorRenderMode !== 'light' && ctorRenderMode !== 'shadow') {
@@ -3615,11 +3704,16 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3615
3704
  disconnectedCallback,
3616
3705
  renderedCallback,
3617
3706
  errorCallback,
3707
+ formAssociatedCallback,
3708
+ formResetCallback,
3709
+ formDisabledCallback,
3710
+ formStateRestoreCallback,
3618
3711
  render
3619
3712
  } = proto;
3620
3713
  const superProto = getCtorProto(Ctor);
3621
- const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
3622
- const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
3714
+ const hasCustomSuperClass = superProto !== LightningElement;
3715
+ const superDef = hasCustomSuperClass ? getComponentInternalDef(superProto) : lightingElementDef;
3716
+ const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods), keys(observedFields), proto, hasCustomSuperClass);
3623
3717
  const props = assign(create(null), superDef.props, apiFields);
3624
3718
  const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
3625
3719
  const methods = assign(create(null), superDef.methods, apiMethods);
@@ -3628,6 +3722,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3628
3722
  disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
3629
3723
  renderedCallback = renderedCallback || superDef.renderedCallback;
3630
3724
  errorCallback = errorCallback || superDef.errorCallback;
3725
+ formAssociatedCallback = formAssociatedCallback || superDef.formAssociatedCallback;
3726
+ formResetCallback = formResetCallback || superDef.formResetCallback;
3727
+ formDisabledCallback = formDisabledCallback || superDef.formDisabledCallback;
3728
+ formStateRestoreCallback = formStateRestoreCallback || superDef.formStateRestoreCallback;
3631
3729
  render = render || superDef.render;
3632
3730
  let shadowSupportMode = superDef.shadowSupportMode;
3633
3731
  if (!isUndefined$1(ctorShadowSupportMode)) {
@@ -3638,6 +3736,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3638
3736
  renderMode = ctorRenderMode === 'light' ? 0 /* RenderMode.Light */ : 1 /* RenderMode.Shadow */;
3639
3737
  }
3640
3738
 
3739
+ let formAssociated = superDef.formAssociated;
3740
+ if (!isUndefined$1(ctorFormAssociated)) {
3741
+ formAssociated = ctorFormAssociated;
3742
+ }
3641
3743
  const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
3642
3744
  const name = Ctor.name || superDef.name;
3643
3745
  // installing observed fields into the prototype.
@@ -3653,10 +3755,15 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3653
3755
  template,
3654
3756
  renderMode,
3655
3757
  shadowSupportMode,
3758
+ formAssociated,
3656
3759
  connectedCallback,
3657
3760
  disconnectedCallback,
3658
- renderedCallback,
3659
3761
  errorCallback,
3762
+ formAssociatedCallback,
3763
+ formDisabledCallback,
3764
+ formResetCallback,
3765
+ formStateRestoreCallback,
3766
+ renderedCallback,
3660
3767
  render
3661
3768
  };
3662
3769
  // This is a no-op unless Lightning DevTools are enabled.
@@ -3733,6 +3840,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3733
3840
  methods: EmptyObject,
3734
3841
  renderMode: 1 /* RenderMode.Shadow */,
3735
3842
  shadowSupportMode: "reset" /* ShadowSupportMode.Default */,
3843
+ formAssociated: undefined,
3736
3844
  wire: EmptyObject,
3737
3845
  bridge: BaseBridgeElement,
3738
3846
  template: defaultEmptyTemplate,
@@ -3795,7 +3903,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3795
3903
  }
3796
3904
  }, [api.t(content)]);
3797
3905
  }
3798
- function updateStylesheetToken(vm, template) {
3906
+ // TODO [#3733]: remove support for legacy scope tokens
3907
+ function updateStylesheetToken(vm, template, legacy) {
3799
3908
  const {
3800
3909
  elm,
3801
3910
  context,
@@ -3808,9 +3917,9 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3808
3917
  }
3809
3918
  } = vm;
3810
3919
  const {
3811
- stylesheets: newStylesheets,
3812
- stylesheetToken: newStylesheetToken
3920
+ stylesheets: newStylesheets
3813
3921
  } = template;
3922
+ const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
3814
3923
  const {
3815
3924
  stylesheets: newVmStylesheets
3816
3925
  } = vm;
@@ -3822,11 +3931,18 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3822
3931
  let newHasTokenInClass;
3823
3932
  let newHasTokenInAttribute;
3824
3933
  // Reset the styling token applied to the host element.
3825
- const {
3826
- stylesheetToken: oldToken,
3827
- hasTokenInClass: oldHasTokenInClass,
3828
- hasTokenInAttribute: oldHasTokenInAttribute
3829
- } = context;
3934
+ let oldToken;
3935
+ let oldHasTokenInClass;
3936
+ let oldHasTokenInAttribute;
3937
+ if (legacy) {
3938
+ oldToken = context.legacyStylesheetToken;
3939
+ oldHasTokenInClass = context.hasLegacyTokenInClass;
3940
+ oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
3941
+ } else {
3942
+ oldToken = context.stylesheetToken;
3943
+ oldHasTokenInClass = context.hasTokenInClass;
3944
+ oldHasTokenInAttribute = context.hasTokenInAttribute;
3945
+ }
3830
3946
  if (!isUndefined$1(oldToken)) {
3831
3947
  if (oldHasTokenInClass) {
3832
3948
  getClassList(elm).remove(makeHostToken(oldToken));
@@ -3854,9 +3970,15 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3854
3970
  }
3855
3971
  }
3856
3972
  // Update the styling tokens present on the context object.
3857
- context.stylesheetToken = newToken;
3858
- context.hasTokenInClass = newHasTokenInClass;
3859
- context.hasTokenInAttribute = newHasTokenInAttribute;
3973
+ if (legacy) {
3974
+ context.legacyStylesheetToken = newToken;
3975
+ context.hasLegacyTokenInClass = newHasTokenInClass;
3976
+ context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
3977
+ } else {
3978
+ context.stylesheetToken = newToken;
3979
+ context.hasTokenInClass = newHasTokenInClass;
3980
+ context.hasTokenInAttribute = newHasTokenInAttribute;
3981
+ }
3860
3982
  }
3861
3983
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3862
3984
  const content = [];
@@ -3940,12 +4062,13 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
3940
4062
  * this returns the unique token for that scoped stylesheet. Otherwise
3941
4063
  * it returns null.
3942
4064
  */
3943
- function getScopeTokenClass(owner) {
4065
+ // TODO [#3733]: remove support for legacy scope tokens
4066
+ function getScopeTokenClass(owner, legacy) {
3944
4067
  const {
3945
4068
  cmpTemplate,
3946
4069
  context
3947
4070
  } = owner;
3948
- return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
4071
+ return context.hasScopedStyles && (legacy ? cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.legacyStylesheetToken : cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
3949
4072
  }
3950
4073
  /**
3951
4074
  * This function returns the host style token for a custom element if it
@@ -4097,32 +4220,22 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4097
4220
  return sel === 'input' && (key === 'value' || key === 'checked');
4098
4221
  }
4099
4222
  function patchProps(oldVnode, vnode, renderer) {
4100
- let {
4101
- props
4102
- } = vnode.data;
4103
4223
  const {
4104
- spread
4224
+ props
4105
4225
  } = vnode.data;
4106
- if (isUndefined$1(props) && isUndefined$1(spread)) {
4226
+ if (isUndefined$1(props)) {
4107
4227
  return;
4108
4228
  }
4109
4229
  let oldProps;
4110
4230
  if (!isNull(oldVnode)) {
4111
4231
  oldProps = oldVnode.data.props;
4112
- const oldSpread = oldVnode.data.spread;
4113
4232
  // Props may be the same due to the static content optimization, so we can skip diffing
4114
- if (oldProps === props && oldSpread === spread) {
4233
+ if (oldProps === props) {
4115
4234
  return;
4116
4235
  }
4117
4236
  if (isUndefined$1(oldProps)) {
4118
4237
  oldProps = EmptyObject;
4119
4238
  }
4120
- if (!isUndefined$1(oldSpread)) {
4121
- oldProps = assign({}, oldProps, oldSpread);
4122
- }
4123
- }
4124
- if (!isUndefined$1(spread)) {
4125
- props = assign({}, props, spread);
4126
4239
  }
4127
4240
  const isFirstPatch = isNull(oldVnode);
4128
4241
  const {
@@ -4332,6 +4445,118 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4332
4445
  }
4333
4446
  }
4334
4447
 
4448
+ /*
4449
+ * Copyright (c) 2023, salesforce.com, inc.
4450
+ * All rights reserved.
4451
+ * SPDX-License-Identifier: MIT
4452
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4453
+ */
4454
+ // Set a ref (lwc:ref) on a VM, from a template API
4455
+ function applyRefs(vnode, owner) {
4456
+ const {
4457
+ data
4458
+ } = vnode;
4459
+ const {
4460
+ ref
4461
+ } = data;
4462
+ if (isUndefined$1(ref)) {
4463
+ return;
4464
+ }
4465
+ if (process.env.NODE_ENV !== 'production' && isUndefined$1(owner.refVNodes)) {
4466
+ throw new Error('refVNodes must be defined when setting a ref');
4467
+ }
4468
+ // If this method is called, then vm.refVNodes is set as the template has refs.
4469
+ // If not, then something went wrong and we threw an error above.
4470
+ const refVNodes = owner.refVNodes;
4471
+ // In cases of conflict (two elements with the same ref), prefer the last one,
4472
+ // in depth-first traversal order. This happens automatically due to how we render
4473
+ refVNodes[ref] = vnode;
4474
+ }
4475
+
4476
+ /*
4477
+ * Copyright (c) 2023, salesforce.com, inc.
4478
+ * All rights reserved.
4479
+ * SPDX-License-Identifier: MIT
4480
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4481
+ */
4482
+ function traverseAndSetElements(root, parts, renderer) {
4483
+ const numParts = parts.length;
4484
+ // Optimization given that, in most cases, there will be one part, and it's just the root
4485
+ if (numParts === 1) {
4486
+ const firstPart = parts[0];
4487
+ if (firstPart.partId === 0) {
4488
+ // 0 means the root node
4489
+ firstPart.elm = root;
4490
+ return;
4491
+ }
4492
+ }
4493
+ const partIdsToParts = new Map();
4494
+ for (const staticPart of parts) {
4495
+ partIdsToParts.set(staticPart.partId, staticPart);
4496
+ }
4497
+ let numFoundParts = 0;
4498
+ const {
4499
+ previousSibling,
4500
+ getLastChild
4501
+ } = renderer;
4502
+ const stack = [root];
4503
+ let partId = -1;
4504
+ // Depth-first traversal. We assign a partId to each element, which is an integer based on traversal order.
4505
+ while (stack.length > 0) {
4506
+ const elm = ArrayShift.call(stack);
4507
+ partId++;
4508
+ const part = partIdsToParts.get(partId);
4509
+ if (!isUndefined$1(part)) {
4510
+ part.elm = elm;
4511
+ if (++numFoundParts === numParts) {
4512
+ return; // perf optimization - stop traversing once we've found everything we need
4513
+ }
4514
+ }
4515
+ // For depth-first traversal, prepend to the stack in reverse order
4516
+ // Note that we traverse using `*Child`/`*Sibling` rather than `children` because the browser uses a linked
4517
+ // list under the hood to represent the DOM tree, so it's faster to do this than to create an underlying array
4518
+ // by calling `children`.
4519
+ let child = getLastChild(elm);
4520
+ while (!isNull(child)) {
4521
+ ArrayUnshift.call(stack, child);
4522
+ child = previousSibling(child);
4523
+ }
4524
+ }
4525
+ if (process.env.NODE_ENV !== 'production') {
4526
+ assert.isTrue(numFoundParts === numParts, `Should have found all parts by now. Found ${numFoundParts}, needed ${numParts}.`);
4527
+ }
4528
+ }
4529
+ /**
4530
+ * Given an array of static parts, do all the mounting required for these parts.
4531
+ *
4532
+ * @param root - the root element
4533
+ * @param vnode - the parent VStatic
4534
+ * @param renderer - the renderer to use
4535
+ * @param mount - true this is a first (mount) render as opposed to a subsequent (patch) render
4536
+ */
4537
+ function applyStaticParts(root, vnode, renderer, mount) {
4538
+ const {
4539
+ parts,
4540
+ owner
4541
+ } = vnode;
4542
+ if (isUndefined$1(parts)) {
4543
+ return;
4544
+ }
4545
+ // This adds `part.elm` to each `part`. We have to do this on every mount/patch because the `parts`
4546
+ // array is recreated from scratch every time, so each `part.elm` is now undefined.
4547
+ // TODO [#3800]: avoid calling traverseAndSetElements on every re-render
4548
+ traverseAndSetElements(root, parts, renderer);
4549
+ // Currently only event listeners and refs are supported for static vnodes
4550
+ for (const part of parts) {
4551
+ if (mount) {
4552
+ // Event listeners only need to be applied once when mounting
4553
+ applyEventListeners(part, renderer);
4554
+ }
4555
+ // Refs must be updated after every render due to refVNodes getting reset before every render
4556
+ applyRefs(part, owner);
4557
+ }
4558
+ }
4559
+
4335
4560
  /*
4336
4561
  * Copyright (c) 2018, salesforce.com, inc.
4337
4562
  * All rights reserved.
@@ -4376,7 +4601,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4376
4601
  patchComment(n1, n2, renderer);
4377
4602
  break;
4378
4603
  case 4 /* VNodeType.Static */:
4379
- n2.elm = n1.elm;
4604
+ patchStatic(n1, n2, renderer);
4380
4605
  break;
4381
4606
  case 5 /* VNodeType.Fragment */:
4382
4607
  patchFragment(n1, n2, parent, renderer);
@@ -4490,13 +4715,18 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4490
4715
  applyStyleScoping(elm, owner, renderer);
4491
4716
  applyDomManual(elm, vnode);
4492
4717
  applyElementRestrictions(elm, vnode);
4493
- patchElementPropsAndAttrs$1(null, vnode, renderer);
4718
+ patchElementPropsAndAttrsAndRefs$1(null, vnode, renderer);
4494
4719
  insertNode(elm, parent, anchor, renderer);
4495
4720
  mountVNodes(vnode.children, elm, renderer, null);
4496
4721
  }
4722
+ function patchStatic(n1, n2, renderer) {
4723
+ const elm = n2.elm = n1.elm;
4724
+ // The `refs` object is blown away in every re-render, so we always need to re-apply them
4725
+ applyStaticParts(elm, n2, renderer, false);
4726
+ }
4497
4727
  function patchElement(n1, n2, renderer) {
4498
4728
  const elm = n2.elm = n1.elm;
4499
- patchElementPropsAndAttrs$1(n1, n2, renderer);
4729
+ patchElementPropsAndAttrsAndRefs$1(n1, n2, renderer);
4500
4730
  patchChildren(n1.children, n2.children, elm, renderer);
4501
4731
  }
4502
4732
  function mountStatic(vnode, parent, anchor, renderer) {
@@ -4521,8 +4751,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4521
4751
  }
4522
4752
  }
4523
4753
  insertNode(elm, parent, anchor, renderer);
4524
- // Event listeners are only applied once when mounting, so they are allowed for static vnodes
4525
- applyEventListeners(vnode, renderer);
4754
+ applyStaticParts(elm, vnode, renderer, true);
4526
4755
  }
4527
4756
  function mountCustomElement(vnode, parent, anchor, renderer) {
4528
4757
  const {
@@ -4545,6 +4774,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4545
4774
  };
4546
4775
  let connectedCallback;
4547
4776
  let disconnectedCallback;
4777
+ let formAssociatedCallback;
4778
+ let formDisabledCallback;
4779
+ let formResetCallback;
4780
+ let formStateRestoreCallback;
4548
4781
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4549
4782
  connectedCallback = elm => {
4550
4783
  connectRootElement(elm);
@@ -4552,13 +4785,25 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4552
4785
  disconnectedCallback = elm => {
4553
4786
  disconnectRootElement(elm);
4554
4787
  };
4788
+ formAssociatedCallback = elm => {
4789
+ runFormAssociatedCallback(elm);
4790
+ };
4791
+ formDisabledCallback = elm => {
4792
+ runFormDisabledCallback(elm);
4793
+ };
4794
+ formResetCallback = elm => {
4795
+ runFormResetCallback(elm);
4796
+ };
4797
+ formStateRestoreCallback = elm => {
4798
+ runFormStateRestoreCallback(elm);
4799
+ };
4555
4800
  }
4556
4801
  // Should never get a tag with upper case letter at this point; the compiler
4557
4802
  // should produce only tags with lowercase letters. However, the Java
4558
4803
  // compiler may generate tagnames with uppercase letters so - for backwards
4559
4804
  // compatibility, we lower case the tagname here.
4560
4805
  const normalizedTagname = sel.toLowerCase();
4561
- const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
4806
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback);
4562
4807
  vnode.elm = elm;
4563
4808
  vnode.vm = vm;
4564
4809
  linkNodeToShadow(elm, owner, renderer);
@@ -4566,7 +4811,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4566
4811
  if (vm) {
4567
4812
  allocateChildren(vnode, vm);
4568
4813
  }
4569
- patchElementPropsAndAttrs$1(null, vnode, renderer);
4814
+ patchElementPropsAndAttrsAndRefs$1(null, vnode, renderer);
4570
4815
  insertNode(elm, parent, anchor, renderer);
4571
4816
  if (vm) {
4572
4817
  {
@@ -4597,7 +4842,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4597
4842
  // Otherwise patch the existing component with new props/attrs/etc.
4598
4843
  const elm = n2.elm = n1.elm;
4599
4844
  const vm = n2.vm = n1.vm;
4600
- patchElementPropsAndAttrs$1(n1, n2, renderer);
4845
+ patchElementPropsAndAttrsAndRefs$1(n1, n2, renderer);
4601
4846
  if (!isUndefined$1(vm)) {
4602
4847
  // in fallback mode, the allocation will always set children to
4603
4848
  // empty and delegate the real allocation to the slot elements
@@ -4762,7 +5007,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4762
5007
  lockDomMutation();
4763
5008
  }
4764
5009
  }
4765
- function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
5010
+ function patchElementPropsAndAttrsAndRefs$1(oldVnode, vnode, renderer) {
4766
5011
  if (isNull(oldVnode)) {
4767
5012
  applyEventListeners(vnode, renderer);
4768
5013
  applyStaticClassAttribute(vnode, renderer);
@@ -4774,24 +5019,43 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
4774
5019
  patchStyleAttribute(oldVnode, vnode, renderer);
4775
5020
  patchAttributes(oldVnode, vnode, renderer);
4776
5021
  patchProps(oldVnode, vnode, renderer);
5022
+ // The `refs` object is blown away in every re-render, so we always need to re-apply them
5023
+ applyRefs(vnode, vnode.owner);
4777
5024
  }
4778
5025
  function applyStyleScoping(elm, owner, renderer) {
5026
+ const {
5027
+ getClassList
5028
+ } = renderer;
4779
5029
  // Set the class name for `*.scoped.css` style scoping.
4780
- const scopeToken = getScopeTokenClass(owner);
5030
+ const scopeToken = getScopeTokenClass(owner, /* legacy */false);
4781
5031
  if (!isNull(scopeToken)) {
4782
- const {
4783
- getClassList
4784
- } = renderer;
4785
5032
  // TODO [#2762]: this dot notation with add is probably problematic
4786
5033
  // probably we should have a renderer api for just the add operation
4787
5034
  getClassList(elm).add(scopeToken);
4788
5035
  }
5036
+ // TODO [#3733]: remove support for legacy scope tokens
5037
+ if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
5038
+ const legacyScopeToken = getScopeTokenClass(owner, /* legacy */true);
5039
+ if (!isNull(legacyScopeToken)) {
5040
+ // TODO [#2762]: this dot notation with add is probably problematic
5041
+ // probably we should have a renderer api for just the add operation
5042
+ getClassList(elm).add(legacyScopeToken);
5043
+ }
5044
+ }
4789
5045
  // Set property element for synthetic shadow DOM style scoping.
4790
5046
  const {
4791
5047
  stylesheetToken: syntheticToken
4792
5048
  } = owner.context;
4793
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
4794
- elm.$shadowToken$ = syntheticToken;
5049
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
5050
+ if (!isUndefined$1(syntheticToken)) {
5051
+ elm.$shadowToken$ = syntheticToken;
5052
+ }
5053
+ if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
5054
+ const legacyToken = owner.context.legacyStylesheetToken;
5055
+ if (!isUndefined$1(legacyToken)) {
5056
+ elm.$legacyShadowToken$ = legacyToken;
5057
+ }
5058
+ }
4795
5059
  }
4796
5060
  }
4797
5061
  function applyDomManual(elm, vnode) {
@@ -5164,6 +5428,14 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5164
5428
  function addVNodeToChildLWC(vnode) {
5165
5429
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
5166
5430
  }
5431
+ // [s]tatic [p]art
5432
+ function sp(partId, data) {
5433
+ return {
5434
+ partId,
5435
+ data,
5436
+ elm: undefined // elm is defined later
5437
+ };
5438
+ }
5167
5439
  // [s]coped [s]lot [f]actory
5168
5440
  function ssf(slotName, factory) {
5169
5441
  return {
@@ -5177,7 +5449,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5177
5449
  };
5178
5450
  }
5179
5451
  // [st]atic node
5180
- function st(fragment, key, data) {
5452
+ function st(fragment, key, parts) {
5181
5453
  const owner = getVMBeingRendered();
5182
5454
  const vnode = {
5183
5455
  type: 4 /* VNodeType.Static */,
@@ -5186,12 +5458,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5186
5458
  elm: undefined,
5187
5459
  fragment,
5188
5460
  owner,
5189
- data
5461
+ parts
5190
5462
  };
5191
- const ref = data === null || data === void 0 ? void 0 : data.ref;
5192
- if (!isUndefined$1(ref)) {
5193
- setRefVNode(owner, ref, vnode);
5194
- }
5195
5463
  return vnode;
5196
5464
  }
5197
5465
  // [fr]agment node
@@ -5231,8 +5499,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5231
5499
  });
5232
5500
  }
5233
5501
  const {
5234
- key,
5235
- ref
5502
+ key
5236
5503
  } = data;
5237
5504
  const vnode = {
5238
5505
  type: 2 /* VNodeType.Element */,
@@ -5243,9 +5510,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5243
5510
  key,
5244
5511
  owner: vmBeingRendered
5245
5512
  };
5246
- if (!isUndefined$1(ref)) {
5247
- setRefVNode(vmBeingRendered, ref, vnode);
5248
- }
5249
5513
  return vnode;
5250
5514
  }
5251
5515
  // [t]ab[i]ndex function
@@ -5317,11 +5581,17 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5317
5581
  const vmBeingRendered = getVMBeingRendered();
5318
5582
  const {
5319
5583
  renderMode,
5320
- shadowMode
5584
+ shadowMode,
5585
+ apiVersion
5321
5586
  } = vmBeingRendered;
5322
5587
  if (renderMode === 0 /* RenderMode.Light */) {
5323
- sc(children);
5324
- return children;
5588
+ // light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
5589
+ if (isAPIFeatureEnabled(2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */, apiVersion)) {
5590
+ return fr(data.key, children, 0);
5591
+ } else {
5592
+ sc(children);
5593
+ return children;
5594
+ }
5325
5595
  }
5326
5596
  if (shadowMode === 1 /* ShadowMode.Synthetic */) {
5327
5597
  // TODO [#1276]: compiler should give us some sort of indicator when a vnodes collection is dynamic
@@ -5352,8 +5622,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5352
5622
  }
5353
5623
  }
5354
5624
  const {
5355
- key,
5356
- ref
5625
+ key
5357
5626
  } = data;
5358
5627
  let elm, aChildren, vm;
5359
5628
  const vnode = {
@@ -5370,9 +5639,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5370
5639
  vm
5371
5640
  };
5372
5641
  addVNodeToChildLWC(vnode);
5373
- if (!isUndefined$1(ref)) {
5374
- setRefVNode(vmBeingRendered, ref, vnode);
5375
- }
5376
5642
  return vnode;
5377
5643
  }
5378
5644
  // [i]terable node
@@ -5670,7 +5936,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5670
5936
  fid,
5671
5937
  shc,
5672
5938
  ssf,
5673
- ddc
5939
+ ddc,
5940
+ sp
5674
5941
  });
5675
5942
 
5676
5943
  /*
@@ -5814,13 +6081,15 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5814
6081
  const {
5815
6082
  context: {
5816
6083
  hasScopedStyles,
5817
- stylesheetToken
6084
+ stylesheetToken,
6085
+ legacyStylesheetToken
5818
6086
  },
5819
6087
  shadowMode,
5820
6088
  renderer
5821
6089
  } = getVMBeingRendered();
5822
6090
  const hasStyleToken = !isUndefined$1(stylesheetToken);
5823
6091
  const isSyntheticShadow = shadowMode === 1 /* ShadowMode.Synthetic */;
6092
+ const hasLegacyToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS && !isUndefined$1(legacyStylesheetToken);
5824
6093
  let cacheKey = 0;
5825
6094
  if (hasStyleToken && hasScopedStyles) {
5826
6095
  cacheKey |= 1 /* FragmentCache.HAS_SCOPED_STYLE */;
@@ -5830,12 +6099,20 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5830
6099
  cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
5831
6100
  }
5832
6101
 
6102
+ if (hasLegacyToken) {
6103
+ // This isn't strictly required for prod, but it's required for our karma tests
6104
+ // since the lwcRuntimeFlag may change over time
6105
+ cacheKey |= 4 /* FragmentCache.HAS_LEGACY_SCOPE_TOKEN */;
6106
+ }
6107
+
5833
6108
  if (!isUndefined$1(cache[cacheKey])) {
5834
6109
  return cache[cacheKey];
5835
6110
  }
5836
- const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetToken : '';
5837
- const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetToken}"` : '';
5838
- const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetToken : '';
6111
+ // If legacy stylesheet tokens are required, then add them to the rendered string
6112
+ const stylesheetTokenToRender = stylesheetToken + (hasLegacyToken ? ` ${legacyStylesheetToken}` : '');
6113
+ const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetTokenToRender : '';
6114
+ const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetTokenToRender}"` : '';
6115
+ const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetTokenToRender : '';
5839
6116
  let htmlFragment = '';
5840
6117
  for (let i = 0, n = keys.length; i < n; i++) {
5841
6118
  switch (keys[i]) {
@@ -5926,7 +6203,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5926
6203
  // Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
5927
6204
  context.hasScopedStyles = computeHasScopedStyles(html, vm);
5928
6205
  // Update the scoping token on the host element.
5929
- updateStylesheetToken(vm, html);
6206
+ updateStylesheetToken(vm, html, /* legacy */false);
6207
+ if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
6208
+ updateStylesheetToken(vm, html, /* legacy */true);
6209
+ }
5930
6210
  // Evaluate, create stylesheet and cache the produced VNode for future
5931
6211
  // re-rendering.
5932
6212
  const stylesheetsContent = getStylesheetsContent(vm, html);
@@ -5938,8 +6218,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
5938
6218
  // add the VM to the list of host VMs that can be re-rendered if html is swapped
5939
6219
  setActiveVM(vm);
5940
6220
  }
5941
- // reset the refs; they will be set during the tmpl() instantiation
5942
- vm.refVNodes = html.hasRefs ? create(null) : null;
5943
6221
  // right before producing the vnodes, we clear up all internal references
5944
6222
  // to custom elements from the template.
5945
6223
  vm.velements = [];
@@ -6121,6 +6399,17 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6121
6399
  var _a;
6122
6400
  return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
6123
6401
  }
6402
+ function getComponentAPIVersion(Ctor) {
6403
+ const metadata = registeredComponentMap.get(Ctor);
6404
+ const apiVersion = metadata === null || metadata === void 0 ? void 0 : metadata.apiVersion;
6405
+ if (isUndefined$1(apiVersion)) {
6406
+ // This should only occur in our Karma tests; in practice every component
6407
+ // is registered, and so this code path should not get hit. But to be safe,
6408
+ // return the lowest possible version.
6409
+ return LOWEST_API_VERSION;
6410
+ }
6411
+ return apiVersion;
6412
+ }
6124
6413
  function getTemplateReactiveObserver(vm) {
6125
6414
  return createReactiveObserver(() => {
6126
6415
  const {
@@ -6167,48 +6456,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6167
6456
  return wrappedListener;
6168
6457
  }
6169
6458
 
6170
- /*
6171
- * Copyright (c) 2018, salesforce.com, inc.
6172
- * All rights reserved.
6173
- * SPDX-License-Identifier: MIT
6174
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6175
- */
6176
- const Services = create(null);
6177
- const hooks = ['rendered', 'connected', 'disconnected'];
6178
- /**
6179
- * EXPERIMENTAL: This function allows for the registration of "services"
6180
- * in LWC by exposing hooks into the component life-cycle. This API is
6181
- * subject to change or being removed.
6182
- */
6183
- function register(service) {
6184
- if (process.env.NODE_ENV !== 'production') {
6185
- assert.isTrue(isObject(service), `Invalid service declaration, ${service}: service must be an object`);
6186
- }
6187
- for (let i = 0; i < hooks.length; ++i) {
6188
- const hookName = hooks[i];
6189
- if (hookName in service) {
6190
- let l = Services[hookName];
6191
- if (isUndefined$1(l)) {
6192
- Services[hookName] = l = [];
6193
- }
6194
- ArrayPush$1.call(l, service[hookName]);
6195
- }
6196
- }
6197
- }
6198
- function invokeServiceHook(vm, cbs) {
6199
- if (process.env.NODE_ENV !== 'production') {
6200
- assert.isTrue(isArray$1(cbs) && cbs.length > 0, `Optimize invokeServiceHook() to be invoked only when needed`);
6201
- }
6202
- const {
6203
- component,
6204
- def,
6205
- context
6206
- } = vm;
6207
- for (let i = 0, len = cbs.length; i < len; ++i) {
6208
- cbs[i].call(undefined, component, {}, def, context);
6209
- }
6210
- }
6211
-
6212
6459
  /*
6213
6460
  * Copyright (c) 2023, Salesforce.com, inc.
6214
6461
  * All rights reserved.
@@ -6271,7 +6518,13 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6271
6518
  // old vnode.children is removed from the DOM.
6272
6519
  function removeVM(vm) {
6273
6520
  if (process.env.NODE_ENV !== 'production') {
6274
- assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
6521
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6522
+ // With native lifecycle, we cannot be certain that connectedCallback was called before a component
6523
+ // was removed from the VDOM. If the component is disconnected, then connectedCallback will not fire
6524
+ // in native mode, although it will fire in synthetic mode due to appendChild triggering it.
6525
+ // See: W-14037619 for details
6526
+ assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
6527
+ }
6275
6528
  }
6276
6529
  resetComponentStateWhenRemoved(vm);
6277
6530
  }
@@ -6290,6 +6543,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6290
6543
  hydrated
6291
6544
  } = options;
6292
6545
  const def = getComponentInternalDef(ctor);
6546
+ const apiVersion = getComponentAPIVersion(ctor);
6293
6547
  const vm = {
6294
6548
  elm,
6295
6549
  def,
@@ -6316,6 +6570,9 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6316
6570
  stylesheetToken: undefined,
6317
6571
  hasTokenInClass: undefined,
6318
6572
  hasTokenInAttribute: undefined,
6573
+ legacyStylesheetToken: undefined,
6574
+ hasLegacyTokenInClass: undefined,
6575
+ hasLegacyTokenInAttribute: undefined,
6319
6576
  hasScopedStyles: undefined,
6320
6577
  styleVNodes: null,
6321
6578
  tplCache: EmptyObject,
@@ -6333,7 +6590,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6333
6590
  callHook,
6334
6591
  setHook,
6335
6592
  getHook,
6336
- renderer
6593
+ renderer,
6594
+ apiVersion
6337
6595
  };
6338
6596
  if (process.env.NODE_ENV !== 'production') {
6339
6597
  vm.debugInfo = create(null);
@@ -6436,8 +6694,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6436
6694
  // ShadowMode.Native implies "not synthetic shadow" which is consistent with how
6437
6695
  // everything defaults to native when the synthetic shadow polyfill is unavailable.
6438
6696
  shadowMode = 0 /* ShadowMode.Native */;
6439
- } else if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
6440
- if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
6697
+ } else if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE || def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6698
+ if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */ || def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6441
6699
  shadowMode = 0 /* ShadowMode.Native */;
6442
6700
  } else {
6443
6701
  const shadowAncestor = getNearestShadowAncestor(owner);
@@ -6497,6 +6755,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6497
6755
  children: oldCh,
6498
6756
  renderer
6499
6757
  } = vm;
6758
+ // reset the refs; they will be set during `patchChildren`
6759
+ resetRefVNodes(vm);
6500
6760
  // caching the new children collection
6501
6761
  vm.children = newCh;
6502
6762
  if (newCh.length > 0 || oldCh.length > 0) {
@@ -6529,12 +6789,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6529
6789
  renderedCallback
6530
6790
  }
6531
6791
  } = vm;
6532
- const {
6533
- rendered
6534
- } = Services;
6535
- if (rendered) {
6536
- invokeServiceHook(vm, rendered);
6537
- }
6538
6792
  if (!isUndefined$1(renderedCallback)) {
6539
6793
  logOperationStart(4 /* OperationId.RenderedCallback */, vm);
6540
6794
  invokeComponentCallback(vm, renderedCallback);
@@ -6581,13 +6835,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6581
6835
  }
6582
6836
 
6583
6837
  vm.state = 1 /* VMState.connected */;
6584
- // reporting connection
6585
- const {
6586
- connected
6587
- } = Services;
6588
- if (connected) {
6589
- invokeServiceHook(vm, connected);
6590
- }
6591
6838
  if (hasWireAdapters(vm)) {
6592
6839
  connectWireAdapters(vm);
6593
6840
  }
@@ -6599,6 +6846,18 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6599
6846
  invokeComponentCallback(vm, connectedCallback);
6600
6847
  logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
6601
6848
  }
6849
+ // This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
6850
+ // we're in dev mode. This is to detect a particular issue with synthetic lifecycle.
6851
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE && (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
6852
+ if (!vm.renderer.isConnected(vm.elm)) {
6853
+ if (process.env.NODE_ENV !== 'production') {
6854
+ logWarnOnce(`Element <${vm.tagName}> ` + `fired a \`connectedCallback\` and rendered, but was not connected to the DOM. ` + `Please ensure all components are actually connected to the DOM, e.g. using ` + `\`document.body.appendChild(element)\`. This will not be supported in future versions of ` + `LWC and could cause component errors. For details, see: https://sfdc.co/synthetic-lifecycle`);
6855
+ }
6856
+ report("ConnectedCallbackWhileDisconnected" /* ReportingEventId.ConnectedCallbackWhileDisconnected */, {
6857
+ tagName: vm.tagName
6858
+ });
6859
+ }
6860
+ }
6602
6861
  }
6603
6862
  function hasWireAdapters(vm) {
6604
6863
  return getOwnPropertyNames$1(vm.def.wire).length > 0;
@@ -6615,13 +6874,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6615
6874
  vm.isDirty = true;
6616
6875
  }
6617
6876
  vm.state = 2 /* VMState.disconnected */;
6618
- // reporting disconnection
6619
- const {
6620
- disconnected
6621
- } = Services;
6622
- if (disconnected) {
6623
- invokeServiceHook(vm, disconnected);
6624
- }
6625
6877
  if (hasWireAdapters(vm)) {
6626
6878
  disconnectWireAdapters(vm);
6627
6879
  }
@@ -6757,6 +7009,11 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6757
7009
  if (!isUndefined$1(error)) {
6758
7010
  addErrorComponentStack(vm, error);
6759
7011
  const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
7012
+ // Error boundaries are not in effect when server-side rendering. `errorCallback`
7013
+ // is intended to allow recovery from errors - changing the state of a component
7014
+ // and instigating a re-render. That is at odds with the single-pass, synchronous
7015
+ // nature of SSR. For that reason, all errors bubble up to the `renderComponent`
7016
+ // call site.
6760
7017
  if (isUndefined$1(errorBoundaryVm)) {
6761
7018
  throw error; // eslint-disable-line no-unsafe-finally
6762
7019
  }
@@ -6786,6 +7043,68 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6786
7043
  scheduleRehydration(vm);
6787
7044
  }
6788
7045
  }
7046
+ function runFormAssociatedCustomElementCallback(vm, faceCb) {
7047
+ const {
7048
+ renderMode,
7049
+ shadowMode,
7050
+ def: {
7051
+ formAssociated
7052
+ }
7053
+ } = vm;
7054
+ // Technically the UpgradableConstructor always sets `static formAssociated = true` but silently fail here to match browser behavior.
7055
+ if (isUndefined$1(formAssociated) || isFalse(formAssociated)) {
7056
+ if (process.env.NODE_ENV !== 'production') {
7057
+ logWarn(`Form associated lifecycle methods must have the 'static formAssociated' value set in the component's prototype chain.`);
7058
+ }
7059
+ return;
7060
+ }
7061
+ if (shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode !== 0 /* RenderMode.Light */) {
7062
+ throw new Error('Form associated lifecycle methods are not available in synthetic shadow. Please use native shadow or light DOM.');
7063
+ }
7064
+ invokeComponentCallback(vm, faceCb);
7065
+ }
7066
+ function runFormAssociatedCallback(elm) {
7067
+ const vm = getAssociatedVM(elm);
7068
+ const {
7069
+ formAssociatedCallback
7070
+ } = vm.def;
7071
+ if (!isUndefined$1(formAssociatedCallback)) {
7072
+ runFormAssociatedCustomElementCallback(vm, formAssociatedCallback);
7073
+ }
7074
+ }
7075
+ function runFormDisabledCallback(elm) {
7076
+ const vm = getAssociatedVM(elm);
7077
+ const {
7078
+ formDisabledCallback
7079
+ } = vm.def;
7080
+ if (!isUndefined$1(formDisabledCallback)) {
7081
+ runFormAssociatedCustomElementCallback(vm, formDisabledCallback);
7082
+ }
7083
+ }
7084
+ function runFormResetCallback(elm) {
7085
+ const vm = getAssociatedVM(elm);
7086
+ const {
7087
+ formResetCallback
7088
+ } = vm.def;
7089
+ if (!isUndefined$1(formResetCallback)) {
7090
+ runFormAssociatedCustomElementCallback(vm, formResetCallback);
7091
+ }
7092
+ }
7093
+ function runFormStateRestoreCallback(elm) {
7094
+ const vm = getAssociatedVM(elm);
7095
+ const {
7096
+ formStateRestoreCallback
7097
+ } = vm.def;
7098
+ if (!isUndefined$1(formStateRestoreCallback)) {
7099
+ runFormAssociatedCustomElementCallback(vm, formStateRestoreCallback);
7100
+ }
7101
+ }
7102
+ function resetRefVNodes(vm) {
7103
+ const {
7104
+ cmpTemplate
7105
+ } = vm;
7106
+ vm.refVNodes = !isNull(cmpTemplate) && cmpTemplate.hasRefs ? create(null) : null;
7107
+ }
6789
7108
 
6790
7109
  /*
6791
7110
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6953,10 +7272,11 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6953
7272
  //
6954
7273
  // See the README for @lwc/aria-reflection
6955
7274
  const NON_STANDARD_ARIA_PROPS = ['ariaActiveDescendant', 'ariaControls', 'ariaDescribedBy', 'ariaDetails', 'ariaErrorMessage', 'ariaFlowTo', 'ariaLabelledBy', 'ariaOwns'];
6956
- function isLightningElement(elm) {
6957
- // The former case is for `this.prop` (inside component) and the latter is for `element.prop` (outside component).
6958
- // In both cases, we apply the non-standard prop even when the global polyfill is disabled, so this is kosher.
6959
- return elm instanceof LightningElement || elm instanceof BaseBridgeElement;
7275
+ function isGlobalAriaPolyfillLoaded() {
7276
+ // Sniff for the legacy polyfill being loaded. The reason this works is because ariaActiveDescendant is a
7277
+ // non-standard ARIA property reflection that is only supported in our legacy polyfill. See
7278
+ // @lwc/aria-reflection/README.md for details.
7279
+ return !isUndefined$1(getOwnPropertyDescriptor$1(Element.prototype, 'ariaActiveDescendant'));
6960
7280
  }
6961
7281
  function findVM(elm) {
6962
7282
  // If it's a shadow DOM component, then it has a host
@@ -6970,7 +7290,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6970
7290
  // Else it might be a light DOM component. Walk up the tree trying to find the owner
6971
7291
  let parentElement = elm;
6972
7292
  while (!isNull(parentElement = parentElement.parentElement)) {
6973
- if (isLightningElement(parentElement)) {
7293
+ if (parentElement instanceof BaseBridgeElement) {
7294
+ // parentElement is an LWC component
6974
7295
  const vm = getAssociatedVMIfPresent(parentElement);
6975
7296
  if (!isUndefined$1(vm)) {
6976
7297
  return vm;
@@ -6981,25 +7302,23 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
6981
7302
  }
6982
7303
 
6983
7304
  function checkAndReportViolation(elm, prop, isSetter, setValue) {
6984
- if (!isLightningElement(elm)) {
6985
- const vm = findVM(elm);
6986
- if (process.env.NODE_ENV !== 'production') {
6987
- logWarnOnce(`Element <${elm.tagName.toLowerCase()}> ` + (isUndefined$1(vm) ? '' : `owned by <${vm.elm.tagName.toLowerCase()}> `) + `uses non-standard property "${prop}". This will be removed in a future version of LWC. ` + `See https://sfdc.co/deprecated-aria`);
6988
- }
6989
- let setValueType;
6990
- if (isSetter) {
6991
- // `typeof null` is "object" which is not very useful for detecting null.
6992
- // We mostly want to know null vs undefined vs other types here, due to
6993
- // https://github.com/salesforce/lwc/issues/3284
6994
- setValueType = isNull(setValue) ? 'null' : typeof setValue;
6995
- }
6996
- report("NonStandardAriaReflection" /* ReportingEventId.NonStandardAriaReflection */, {
6997
- tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
6998
- propertyName: prop,
6999
- isSetter,
7000
- setValueType
7001
- });
7002
- }
7305
+ const vm = findVM(elm);
7306
+ if (process.env.NODE_ENV !== 'production') {
7307
+ logWarnOnce(`Element <${elm.tagName.toLowerCase()}> ` + (isUndefined$1(vm) ? '' : `owned by <${vm.elm.tagName.toLowerCase()}> `) + `uses non-standard property "${prop}". This will be removed in a future version of LWC. ` + `See https://sfdc.co/deprecated-aria`);
7308
+ }
7309
+ let setValueType;
7310
+ if (isSetter) {
7311
+ // `typeof null` is "object" which is not very useful for detecting null.
7312
+ // We mostly want to know null vs undefined vs other types here, due to
7313
+ // https://github.com/salesforce/lwc/issues/3284
7314
+ setValueType = isNull(setValue) ? 'null' : typeof setValue;
7315
+ }
7316
+ report("NonStandardAriaReflection" /* ReportingEventId.NonStandardAriaReflection */, {
7317
+ tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
7318
+ propertyName: prop,
7319
+ isSetter,
7320
+ setValueType
7321
+ });
7003
7322
  }
7004
7323
  function enableDetection() {
7005
7324
  const {
@@ -7021,6 +7340,9 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7021
7340
  get,
7022
7341
  set
7023
7342
  } = descriptor;
7343
+ // It's important for this defineProperty call to happen _after_ ARIA accessors are applied to the
7344
+ // BaseBridgeElement and LightningElement prototypes. Otherwise, we will log/report for access of non-standard
7345
+ // props on these prototypes, which we actually don't want. We only care about access on generic HTMLElements.
7024
7346
  defineProperty(prototype, prop, {
7025
7347
  get() {
7026
7348
  checkAndReportViolation(this, prop, false, undefined);
@@ -7036,15 +7358,13 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7036
7358
  }
7037
7359
  }
7038
7360
  // No point in running this code if we're not in a browser, or if the global polyfill is not loaded
7039
- {
7040
- if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
7041
- // Always run detection in dev mode, so we can at least print to the console
7042
- if (process.env.NODE_ENV !== 'production') {
7043
- enableDetection();
7044
- } else {
7045
- // In prod mode, only enable detection if reporting is enabled
7046
- onReportingEnabled(enableDetection);
7047
- }
7361
+ if (isGlobalAriaPolyfillLoaded()) {
7362
+ // Always run detection in dev mode, so we can at least print to the console
7363
+ if (process.env.NODE_ENV !== 'production') {
7364
+ enableDetection();
7365
+ } else {
7366
+ // In prod mode, only enable detection if reporting is enabled
7367
+ onReportingEnabled(enableDetection);
7048
7368
  }
7049
7369
  }
7050
7370
 
@@ -7067,6 +7387,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7067
7387
  function hydrateVM(vm) {
7068
7388
  const children = renderComponent(vm);
7069
7389
  vm.children = children;
7390
+ // reset the refs; they will be set during `hydrateChildren`
7391
+ resetRefVNodes(vm);
7070
7392
  const {
7071
7393
  renderRoot: parentNode,
7072
7394
  renderer: {
@@ -7187,7 +7509,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7187
7509
  return handleMismatch(elm, vnode, renderer);
7188
7510
  }
7189
7511
  vnode.elm = elm;
7190
- applyEventListeners(vnode, renderer);
7512
+ applyStaticParts(elm, vnode, renderer, true);
7191
7513
  return elm;
7192
7514
  }
7193
7515
  function hydrateFragment(elm, vnode, renderer) {
@@ -7234,7 +7556,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7234
7556
  }
7235
7557
  }
7236
7558
  }
7237
- patchElementPropsAndAttrs(vnode, renderer);
7559
+ patchElementPropsAndAttrsAndRefs(vnode, renderer);
7238
7560
  if (!isDomManual) {
7239
7561
  const {
7240
7562
  getFirstChild
@@ -7266,6 +7588,11 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7266
7588
  ctor,
7267
7589
  owner
7268
7590
  } = vnode;
7591
+ const {
7592
+ defineCustomElement,
7593
+ getTagName
7594
+ } = renderer;
7595
+ defineCustomElement(StringToLowerCase.call(getTagName(elm)));
7269
7596
  const vm = createVM(elm, ctor, renderer, {
7270
7597
  mode,
7271
7598
  owner,
@@ -7275,7 +7602,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7275
7602
  vnode.elm = elm;
7276
7603
  vnode.vm = vm;
7277
7604
  allocateChildren(vnode, vm);
7278
- patchElementPropsAndAttrs(vnode, renderer);
7605
+ patchElementPropsAndAttrsAndRefs(vnode, renderer);
7279
7606
  // Insert hook section:
7280
7607
  if (process.env.NODE_ENV !== 'production') {
7281
7608
  assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
@@ -7347,9 +7674,11 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7347
7674
  removeNode(node, parentNode, renderer);
7348
7675
  return vnode.elm;
7349
7676
  }
7350
- function patchElementPropsAndAttrs(vnode, renderer) {
7677
+ function patchElementPropsAndAttrsAndRefs(vnode, renderer) {
7351
7678
  applyEventListeners(vnode, renderer);
7352
7679
  patchProps(null, vnode, renderer);
7680
+ // The `refs` object is blown away in every re-render, so we always need to re-apply them
7681
+ applyRefs(vnode, vnode.owner);
7353
7682
  }
7354
7683
  function hasCorrectNodeType(vnode, node, nodeType, renderer) {
7355
7684
  const {
@@ -7437,7 +7766,8 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7437
7766
  getClassList,
7438
7767
  getAttribute
7439
7768
  } = renderer;
7440
- const scopedToken = getScopeTokenClass(owner);
7769
+ // we don't care about legacy for hydration. it's a new use case
7770
+ const scopedToken = getScopeTokenClass(owner, /* legacy */false);
7441
7771
  const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
7442
7772
  // Classnames for scoped CSS are added directly to the DOM during rendering,
7443
7773
  // or to the VDOM on the server in the case of SSR. As such, these classnames
@@ -7748,7 +8078,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7748
8078
  }
7749
8079
  function addLegacyStylesheetTokensShim(tmpl) {
7750
8080
  // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
7751
- // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
8081
+ // is accessing the old internal API (backwards compat). Details: W-14210169
7752
8082
  defineProperty(tmpl, 'stylesheetTokens', {
7753
8083
  enumerable: true,
7754
8084
  configurable: true,
@@ -7841,7 +8171,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
7841
8171
  }
7842
8172
  return getReadOnlyProxy(obj);
7843
8173
  }
7844
- /** version: 3.2.0 */
8174
+ /** version: 4.0.1 */
7845
8175
 
7846
8176
  /*
7847
8177
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8057,6 +8387,14 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8057
8387
  const cachedConstructors = new Map();
8058
8388
  const elementsUpgradedOutsideLWC = new WeakSet();
8059
8389
  let elementBeingUpgradedByLWC = false;
8390
+ let formAssociatedCallbackToUse;
8391
+ let formDisabledCallbackToUse;
8392
+ let formResetCallbackToUse;
8393
+ let formStateRestoreCallbackToUse;
8394
+ const instancesToFormAssociatedCallbacks = new WeakMap();
8395
+ const instancesToFormDisabledCallbacks = new WeakMap();
8396
+ const instancesToFormResetCallbacks = new WeakMap();
8397
+ const instancesToFormStateRestoreCallbacks = new WeakMap();
8060
8398
  // Creates a constructor that is intended to be used directly as a custom element, except that the upgradeCallback is
8061
8399
  // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
8062
8400
  // Another benefit is that only LWC can create components that actually do anything – if you do
@@ -8072,6 +8410,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8072
8410
  // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
8073
8411
  // then elementBeingUpgraded will be false
8074
8412
  if (elementBeingUpgradedByLWC) {
8413
+ instancesToFormAssociatedCallbacks.set(this, formAssociatedCallbackToUse);
8414
+ instancesToFormDisabledCallbacks.set(this, formDisabledCallbackToUse);
8415
+ instancesToFormResetCallbacks.set(this, formResetCallbackToUse);
8416
+ instancesToFormStateRestoreCallbacks.set(this, formStateRestoreCallbackToUse);
8075
8417
  upgradeCallback(this);
8076
8418
  } else if (hasConnectedCallback || hasDisconnectedCallback) {
8077
8419
  // If this element has connected or disconnected callbacks, then we need to keep track of
@@ -8082,8 +8424,38 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8082
8424
  // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8083
8425
  }
8084
8426
  }
8085
- /*LWC compiler v3.2.0*/
8427
+
8428
+ formAssociatedCallback() {
8429
+ const formAssociatedCallback = instancesToFormAssociatedCallbacks.get(this);
8430
+ // if element was upgraded outside LWC, this will be undefined
8431
+ if (!isUndefined$1(formAssociatedCallback)) {
8432
+ formAssociatedCallback(this);
8433
+ }
8434
+ }
8435
+ formResetCallback() {
8436
+ const formResetCallback = instancesToFormResetCallbacks.get(this);
8437
+ // if element was upgraded outside LWC, this will be undefined
8438
+ if (!isUndefined$1(formResetCallback)) {
8439
+ formResetCallback(this);
8440
+ }
8441
+ }
8442
+ formDisabledCallback() {
8443
+ const formDisabledCallback = instancesToFormDisabledCallbacks.get(this);
8444
+ // if element was upgraded outside LWC, this will be undefined
8445
+ if (!isUndefined$1(formDisabledCallback)) {
8446
+ formDisabledCallback(this);
8447
+ }
8448
+ }
8449
+ formStateRestoreCallback() {
8450
+ const formStateRestoreCallback = instancesToFormStateRestoreCallbacks.get(this);
8451
+ // if element was upgraded outside LWC, this will be undefined
8452
+ if (!isUndefined$1(formStateRestoreCallback)) {
8453
+ formStateRestoreCallback(this);
8454
+ }
8455
+ }
8456
+ /*LWC compiler v4.0.1*/
8086
8457
  }
8458
+ UpgradableConstructor.formAssociated = true;
8087
8459
  // Do not unnecessarily add a connectedCallback/disconnectedCallback, as it introduces perf overhead
8088
8460
  // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
8089
8461
  if (hasConnectedCallback) {
@@ -8102,8 +8474,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8102
8474
  }
8103
8475
  return UpgradableConstructor;
8104
8476
  };
8105
- const createCustomElement = (tagName, upgradeCallback, connectedCallback, disconnectedCallback) => {
8106
- // use global custom elements registry
8477
+ function getUpgradableConstructor(tagName, connectedCallback, disconnectedCallback) {
8107
8478
  let UpgradableConstructor = cachedConstructors.get(tagName);
8108
8479
  if (isUndefined$1(UpgradableConstructor)) {
8109
8480
  if (!isUndefined$1(customElements.get(tagName))) {
@@ -8113,11 +8484,23 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8113
8484
  customElements.define(tagName, UpgradableConstructor);
8114
8485
  cachedConstructors.set(tagName, UpgradableConstructor);
8115
8486
  }
8487
+ return UpgradableConstructor;
8488
+ }
8489
+ const createCustomElement = (tagName, upgradeCallback, connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback) => {
8490
+ const UpgradableConstructor = getUpgradableConstructor(tagName, connectedCallback, disconnectedCallback);
8491
+ formAssociatedCallbackToUse = formAssociatedCallback;
8492
+ formDisabledCallbackToUse = formDisabledCallback;
8493
+ formResetCallbackToUse = formResetCallback;
8494
+ formStateRestoreCallbackToUse = formStateRestoreCallback;
8116
8495
  elementBeingUpgradedByLWC = true;
8117
8496
  try {
8118
8497
  return new UpgradableConstructor(upgradeCallback);
8119
8498
  } finally {
8120
8499
  elementBeingUpgradedByLWC = false;
8500
+ formAssociatedCallbackToUse = undefined;
8501
+ formDisabledCallbackToUse = undefined;
8502
+ formResetCallbackToUse = undefined;
8503
+ formStateRestoreCallbackToUse = undefined;
8121
8504
  }
8122
8505
  };
8123
8506
 
@@ -8179,7 +8562,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8179
8562
  function isNull(obj) {
8180
8563
  return obj === null;
8181
8564
  }
8182
- /** version: 3.2.0 */
8565
+ /** version: 4.0.1 */
8183
8566
 
8184
8567
  /*
8185
8568
  * Copyright (c) 2023, salesforce.com, inc.
@@ -8199,7 +8582,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8199
8582
  this.setNewContext = setNewContext;
8200
8583
  this.setDisconnectedCallback = setDisconnectedCallback;
8201
8584
  }
8202
- /*LWC compiler v3.2.0*/
8585
+ /*LWC compiler v4.0.1*/
8203
8586
  }
8204
8587
  function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
8205
8588
  dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
@@ -8251,6 +8634,9 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8251
8634
  function nextSibling(node) {
8252
8635
  return node.nextSibling;
8253
8636
  }
8637
+ function previousSibling(node) {
8638
+ return node.previousSibling;
8639
+ }
8254
8640
  function attachShadow(element, options) {
8255
8641
  // `shadowRoot` will be non-null in two cases:
8256
8642
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
@@ -8345,13 +8731,15 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8345
8731
  function getTagName(elm) {
8346
8732
  return elm.tagName;
8347
8733
  }
8348
- // Use the attachInternals method from HTMLElement.prototype because access to it is removed
8349
- // in HTMLBridgeElement, ie: elm.attachInternals is undefined.
8350
- // Additionally, cache the attachInternals method to protect against 3rd party monkey-patching.
8351
- const attachInternalsFunc = HTMLElement.prototype.attachInternals;
8352
8734
  function attachInternals(elm) {
8353
8735
  return attachInternalsFunc.call(elm);
8354
8736
  }
8737
+ // Use the attachInternals method from HTMLElement.prototype because access to it is removed
8738
+ // in HTMLBridgeElement, ie: elm.attachInternals is undefined.
8739
+ // Additionally, cache the attachInternals method to protect against 3rd party monkey-patching.
8740
+ const attachInternalsFunc = typeof ElementInternals !== 'undefined' ? HTMLElement.prototype.attachInternals : () => {
8741
+ throw new Error('attachInternals API is not supported in this browser environment.');
8742
+ };
8355
8743
  exports.addEventListener = addEventListener;
8356
8744
  exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
8357
8745
  exports.attachInternals = attachInternals;
@@ -8379,6 +8767,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8379
8767
  exports.isConnected = isConnected;
8380
8768
  exports.nextSibling = nextSibling;
8381
8769
  exports.ownerDocument = ownerDocument;
8770
+ exports.previousSibling = previousSibling;
8382
8771
  exports.querySelector = querySelector;
8383
8772
  exports.querySelectorAll = querySelectorAll;
8384
8773
  exports.registerContextConsumer = registerContextConsumer;
@@ -8417,6 +8806,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8417
8806
  insertStylesheet,
8418
8807
  // relies on a shared global cache
8419
8808
  createCustomElement,
8809
+ defineCustomElement: getUpgradableConstructor,
8420
8810
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
8421
8811
  });
8422
8812
 
@@ -8467,6 +8857,11 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8467
8857
  return;
8468
8858
  }
8469
8859
  try {
8860
+ const {
8861
+ defineCustomElement,
8862
+ getTagName
8863
+ } = renderer;
8864
+ defineCustomElement(StringToLowerCase.call(getTagName(element)));
8470
8865
  const vm = createVMWithProps(element, Ctor, props);
8471
8866
  hydrateRoot(vm);
8472
8867
  } catch (e) {
@@ -8567,7 +8962,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8567
8962
  attributeChangedCallback(name, oldValue, newValue) {
8568
8963
  attributeChangedCallback.call(this, name, oldValue, newValue);
8569
8964
  }
8570
- /*LWC compiler v3.2.0*/
8965
+ /*LWC compiler v4.0.1*/
8571
8966
  }, _a.observedAttributes = observedAttributes, _a;
8572
8967
  }
8573
8968
 
@@ -8669,6 +9064,10 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8669
9064
  };
8670
9065
  let connectedCallback;
8671
9066
  let disconnectedCallback;
9067
+ let formAssociatedCallback;
9068
+ let formDisabledCallback;
9069
+ let formResetCallback;
9070
+ let formStateRestoreCallback;
8672
9071
  if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
8673
9072
  connectedCallback = elm => {
8674
9073
  connectRootElement(elm);
@@ -8676,8 +9075,20 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8676
9075
  disconnectedCallback = elm => {
8677
9076
  disconnectRootElement(elm);
8678
9077
  };
9078
+ formAssociatedCallback = elm => {
9079
+ runFormAssociatedCallback(elm);
9080
+ };
9081
+ formDisabledCallback = elm => {
9082
+ runFormDisabledCallback(elm);
9083
+ };
9084
+ formResetCallback = elm => {
9085
+ runFormResetCallback(elm);
9086
+ };
9087
+ formStateRestoreCallback = elm => {
9088
+ runFormStateRestoreCallback(elm);
9089
+ };
8679
9090
  }
8680
- const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
9091
+ const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback);
8681
9092
  return element;
8682
9093
  }
8683
9094
 
@@ -8781,7 +9192,7 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8781
9192
  });
8782
9193
  });
8783
9194
  }
8784
- /** version: 3.2.0 */
9195
+ /** version: 4.0.1 */
8785
9196
 
8786
9197
  exports.LightningElement = LightningElement;
8787
9198
  exports.__unstable__ProfilerControl = profilerControl;
@@ -8799,7 +9210,6 @@ LWR.define('lwc/v/3_2_0', ['exports'], (function (exports) { 'use strict';
8799
9210
  exports.parseFragment = parseFragment;
8800
9211
  exports.parseSVGFragment = parseSVGFragment;
8801
9212
  exports.readonly = readonly;
8802
- exports.register = register;
8803
9213
  exports.registerComponent = registerComponent;
8804
9214
  exports.registerDecorators = registerDecorators;
8805
9215
  exports.registerTemplate = registerTemplate;