@lwc/engine-core 6.3.1 → 6.3.3

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.
package/dist/index.js CHANGED
@@ -522,6 +522,18 @@ function applyTemporaryCompilerV5SlotFix(data) {
522
522
  }
523
523
  return data;
524
524
  }
525
+ function shouldBeFormAssociated(Ctor) {
526
+ const ctorFormAssociated = Boolean(Ctor.formAssociated);
527
+ const apiVersion = getComponentAPIVersion(Ctor);
528
+ const apiFeatureEnabled = isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
529
+ if (process.env.NODE_ENV !== 'production' && ctorFormAssociated && !apiFeatureEnabled) {
530
+ const tagName = getComponentRegisteredName(Ctor);
531
+ logWarnOnce(`Component <${tagName}> set static formAssociated to true, but form ` +
532
+ `association is not enabled because the API version is ${apiVersion}. To enable form association, ` +
533
+ `update the LWC component API version to 61 or above. https://lwc.dev/guide/versioning`);
534
+ }
535
+ return ctorFormAssociated && apiFeatureEnabled;
536
+ }
525
537
 
526
538
  /*
527
539
  * Copyright (c) 2020, salesforce.com, inc.
@@ -651,7 +663,6 @@ forEach.call(defaultDefHTMLPropertyNames, (propName) => {
651
663
  * SPDX-License-Identifier: MIT
652
664
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
653
665
  */
654
- /* eslint @lwc/lwc-internal/no-production-assert: "off" */
655
666
  function generateDataDescriptor(options) {
656
667
  return assign({
657
668
  configurable: true,
@@ -1757,8 +1768,10 @@ LightningElement.prototype = {
1757
1768
  attachInternals() {
1758
1769
  const vm = getAssociatedVM(this);
1759
1770
  const { elm, apiVersion, renderer: { attachInternals }, } = vm;
1760
- if (!isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS */, apiVersion)) {
1761
- throw new Error(`The attachInternals API is only supported in API version 61 and above. To use this API please update the LWC component API version.`);
1771
+ if (!isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
1772
+ throw new Error(`The attachInternals API is only supported in API version 61 and above. ` +
1773
+ `The current version is ${apiVersion}. ` +
1774
+ `To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`);
1762
1775
  }
1763
1776
  if (vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
1764
1777
  throw new Error('attachInternals API is not supported in synthetic shadow.');
@@ -2001,11 +2014,10 @@ function createObservedFieldPropertyDescriptor(key) {
2001
2014
  */
2002
2015
  const AdapterToTokenMap = new Map();
2003
2016
  function createContextProviderWithRegister(adapter, registerContextProvider) {
2004
- let adapterContextToken = AdapterToTokenMap.get(adapter);
2005
- if (!isUndefined$1(adapterContextToken)) {
2017
+ if (AdapterToTokenMap.has(adapter)) {
2006
2018
  throw new Error(`Adapter already has a context provider.`);
2007
2019
  }
2008
- adapterContextToken = guid();
2020
+ const adapterContextToken = guid();
2009
2021
  AdapterToTokenMap.set(adapter, adapterContextToken);
2010
2022
  const providers = new WeakSet();
2011
2023
  return (elmOrComponent, options) => {
@@ -4237,7 +4249,7 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4237
4249
  // compatibility, we lower case the tagname here.
4238
4250
  const normalizedTagname = sel.toLowerCase();
4239
4251
  const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
4240
- const isFormAssociated = Boolean(ctor.formAssociated);
4252
+ const isFormAssociated = shouldBeFormAssociated(ctor);
4241
4253
  const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle, isFormAssociated);
4242
4254
  vnode.elm = elm;
4243
4255
  vnode.vm = vm;
@@ -5903,7 +5915,7 @@ function getWrappedComponentsListener(vm, listener) {
5903
5915
  }
5904
5916
 
5905
5917
  /*
5906
- * Copyright (c) 2023, Salesforce.com, inc.
5918
+ * Copyright (c) 2024, Salesforce, Inc.
5907
5919
  * All rights reserved.
5908
5920
  * SPDX-License-Identifier: MIT
5909
5921
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -6124,14 +6136,13 @@ function computeShadowAndRenderMode(Ctor, renderer) {
6124
6136
  return { renderMode, shadowMode };
6125
6137
  }
6126
6138
  function computeShadowMode(def, owner, renderer, hydrated) {
6139
+ if (
6127
6140
  // Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
6128
6141
  // on, but components running in actual native shadow mode
6129
- if (process.env.NODE_ENV !== 'production' &&
6130
- lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
6131
- return 0 /* ShadowMode.Native */;
6132
- }
6133
- if (isTrue(hydrated)) {
6142
+ (process.env.NODE_ENV === 'test-karma-lwc' &&
6143
+ process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST) ||
6134
6144
  // hydration only supports native shadow
6145
+ isTrue(hydrated)) {
6135
6146
  return 0 /* ShadowMode.Native */;
6136
6147
  }
6137
6148
  const { isSyntheticShadowDefined } = renderer;
@@ -6967,7 +6978,8 @@ function hydrateCustomElement(elm, vnode, renderer) {
6967
6978
  }
6968
6979
  const { sel, mode, ctor, owner } = vnode;
6969
6980
  const { defineCustomElement, getTagName } = renderer;
6970
- defineCustomElement(StringToLowerCase.call(getTagName(elm)), Boolean(ctor.formAssociated));
6981
+ const isFormAssociated = shouldBeFormAssociated(ctor);
6982
+ defineCustomElement(StringToLowerCase.call(getTagName(elm)), isFormAssociated);
6971
6983
  const vm = createVM(elm, ctor, renderer, {
6972
6984
  mode,
6973
6985
  owner,
@@ -7544,6 +7556,6 @@ function readonly(obj) {
7544
7556
  return getReadOnlyProxy(obj);
7545
7557
  }
7546
7558
 
7547
- export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7548
- /** version: 6.3.1 */
7559
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7560
+ /** version: 6.3.3 */
7549
7561
  //# sourceMappingURL=index.js.map