@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.
@@ -3,7 +3,7 @@ export { RenderMode, ShadowMode, connectRootElement, createVM, disconnectRootEle
3
3
  export { createContextProviderWithRegister } from './wiring';
4
4
  export { parseFragment, parseSVGFragment } from './template';
5
5
  export { hydrateRoot } from './hydration';
6
- export { registerComponent, getComponentAPIVersion } from './component';
6
+ export { registerComponent } from './component';
7
7
  export { registerTemplate } from './secure-template';
8
8
  export { registerDecorators } from './decorators/register';
9
9
  export { unwrap } from './membrane';
@@ -14,6 +14,8 @@ export { reportingControl as __unstable__ReportingControl } from './reporting';
14
14
  export { swapTemplate, swapComponent, swapStyle } from './hot-swaps';
15
15
  export { setHooks } from './overridable-hooks';
16
16
  export { freezeTemplate } from './freeze-template';
17
+ export { getComponentAPIVersion } from './component';
18
+ export { shouldBeFormAssociated } from './utils';
17
19
  export { getComponentConstructor } from './get-component-constructor';
18
20
  export type { RendererAPI, LifecycleCallback } from './renderer';
19
21
  export type { ConfigValue as WireConfigValue, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
@@ -37,4 +37,5 @@ export declare function applyTemporaryCompilerV5SlotFix(data: VElementData): VEl
37
37
  svg?: boolean | undefined;
38
38
  renderer?: import("./renderer").RendererAPI | undefined;
39
39
  };
40
+ export declare function shouldBeFormAssociated(Ctor: LightningElementConstructor): boolean;
40
41
  export {};
package/dist/index.cjs.js CHANGED
@@ -526,6 +526,18 @@ function applyTemporaryCompilerV5SlotFix(data) {
526
526
  }
527
527
  return data;
528
528
  }
529
+ function shouldBeFormAssociated(Ctor) {
530
+ const ctorFormAssociated = Boolean(Ctor.formAssociated);
531
+ const apiVersion = getComponentAPIVersion(Ctor);
532
+ const apiFeatureEnabled = shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
533
+ if (process.env.NODE_ENV !== 'production' && ctorFormAssociated && !apiFeatureEnabled) {
534
+ const tagName = getComponentRegisteredName(Ctor);
535
+ logWarnOnce(`Component <${tagName}> set static formAssociated to true, but form ` +
536
+ `association is not enabled because the API version is ${apiVersion}. To enable form association, ` +
537
+ `update the LWC component API version to 61 or above. https://lwc.dev/guide/versioning`);
538
+ }
539
+ return ctorFormAssociated && apiFeatureEnabled;
540
+ }
529
541
 
530
542
  /*
531
543
  * Copyright (c) 2020, salesforce.com, inc.
@@ -655,7 +667,6 @@ shared.forEach.call(defaultDefHTMLPropertyNames, (propName) => {
655
667
  * SPDX-License-Identifier: MIT
656
668
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
657
669
  */
658
- /* eslint @lwc/lwc-internal/no-production-assert: "off" */
659
670
  function generateDataDescriptor(options) {
660
671
  return shared.assign({
661
672
  configurable: true,
@@ -1761,8 +1772,10 @@ LightningElement.prototype = {
1761
1772
  attachInternals() {
1762
1773
  const vm = getAssociatedVM(this);
1763
1774
  const { elm, apiVersion, renderer: { attachInternals }, } = vm;
1764
- if (!shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS */, apiVersion)) {
1765
- 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.`);
1775
+ if (!shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
1776
+ throw new Error(`The attachInternals API is only supported in API version 61 and above. ` +
1777
+ `The current version is ${apiVersion}. ` +
1778
+ `To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`);
1766
1779
  }
1767
1780
  if (vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
1768
1781
  throw new Error('attachInternals API is not supported in synthetic shadow.');
@@ -2005,11 +2018,10 @@ function createObservedFieldPropertyDescriptor(key) {
2005
2018
  */
2006
2019
  const AdapterToTokenMap = new Map();
2007
2020
  function createContextProviderWithRegister(adapter, registerContextProvider) {
2008
- let adapterContextToken = AdapterToTokenMap.get(adapter);
2009
- if (!shared.isUndefined(adapterContextToken)) {
2021
+ if (AdapterToTokenMap.has(adapter)) {
2010
2022
  throw new Error(`Adapter already has a context provider.`);
2011
2023
  }
2012
- adapterContextToken = guid();
2024
+ const adapterContextToken = guid();
2013
2025
  AdapterToTokenMap.set(adapter, adapterContextToken);
2014
2026
  const providers = new WeakSet();
2015
2027
  return (elmOrComponent, options) => {
@@ -4241,7 +4253,7 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4241
4253
  // compatibility, we lower case the tagname here.
4242
4254
  const normalizedTagname = sel.toLowerCase();
4243
4255
  const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
4244
- const isFormAssociated = Boolean(ctor.formAssociated);
4256
+ const isFormAssociated = shouldBeFormAssociated(ctor);
4245
4257
  const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle, isFormAssociated);
4246
4258
  vnode.elm = elm;
4247
4259
  vnode.vm = vm;
@@ -5907,7 +5919,7 @@ function getWrappedComponentsListener(vm, listener) {
5907
5919
  }
5908
5920
 
5909
5921
  /*
5910
- * Copyright (c) 2023, Salesforce.com, inc.
5922
+ * Copyright (c) 2024, Salesforce, Inc.
5911
5923
  * All rights reserved.
5912
5924
  * SPDX-License-Identifier: MIT
5913
5925
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -6128,14 +6140,13 @@ function computeShadowAndRenderMode(Ctor, renderer) {
6128
6140
  return { renderMode, shadowMode };
6129
6141
  }
6130
6142
  function computeShadowMode(def, owner, renderer, hydrated) {
6143
+ if (
6131
6144
  // Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
6132
6145
  // on, but components running in actual native shadow mode
6133
- if (process.env.NODE_ENV !== 'production' &&
6134
- lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
6135
- return 0 /* ShadowMode.Native */;
6136
- }
6137
- if (shared.isTrue(hydrated)) {
6146
+ (process.env.NODE_ENV === 'test-karma-lwc' &&
6147
+ process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST) ||
6138
6148
  // hydration only supports native shadow
6149
+ shared.isTrue(hydrated)) {
6139
6150
  return 0 /* ShadowMode.Native */;
6140
6151
  }
6141
6152
  const { isSyntheticShadowDefined } = renderer;
@@ -6971,7 +6982,8 @@ function hydrateCustomElement(elm, vnode, renderer) {
6971
6982
  }
6972
6983
  const { sel, mode, ctor, owner } = vnode;
6973
6984
  const { defineCustomElement, getTagName } = renderer;
6974
- defineCustomElement(shared.StringToLowerCase.call(getTagName(elm)), Boolean(ctor.formAssociated));
6985
+ const isFormAssociated = shouldBeFormAssociated(ctor);
6986
+ defineCustomElement(shared.StringToLowerCase.call(getTagName(elm)), isFormAssociated);
6975
6987
  const vm = createVM(elm, ctor, renderer, {
6976
6988
  mode,
6977
6989
  owner,
@@ -7585,11 +7597,12 @@ exports.runFormResetCallback = runFormResetCallback;
7585
7597
  exports.runFormStateRestoreCallback = runFormStateRestoreCallback;
7586
7598
  exports.sanitizeAttribute = sanitizeAttribute;
7587
7599
  exports.setHooks = setHooks;
7600
+ exports.shouldBeFormAssociated = shouldBeFormAssociated;
7588
7601
  exports.swapComponent = swapComponent;
7589
7602
  exports.swapStyle = swapStyle;
7590
7603
  exports.swapTemplate = swapTemplate;
7591
7604
  exports.track = track;
7592
7605
  exports.unwrap = unwrap;
7593
7606
  exports.wire = wire;
7594
- /** version: 6.3.1 */
7607
+ /** version: 6.3.3 */
7595
7608
  //# sourceMappingURL=index.cjs.js.map