@lwc/engine-core 6.3.1 → 6.3.2

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.
@@ -1761,8 +1773,10 @@ LightningElement.prototype = {
1761
1773
  attachInternals() {
1762
1774
  const vm = getAssociatedVM(this);
1763
1775
  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.`);
1776
+ if (!shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
1777
+ throw new Error(`The attachInternals API is only supported in API version 61 and above. ` +
1778
+ `The current version is ${apiVersion}. ` +
1779
+ `To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`);
1766
1780
  }
1767
1781
  if (vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
1768
1782
  throw new Error('attachInternals API is not supported in synthetic shadow.');
@@ -2005,11 +2019,10 @@ function createObservedFieldPropertyDescriptor(key) {
2005
2019
  */
2006
2020
  const AdapterToTokenMap = new Map();
2007
2021
  function createContextProviderWithRegister(adapter, registerContextProvider) {
2008
- let adapterContextToken = AdapterToTokenMap.get(adapter);
2009
- if (!shared.isUndefined(adapterContextToken)) {
2022
+ if (AdapterToTokenMap.has(adapter)) {
2010
2023
  throw new Error(`Adapter already has a context provider.`);
2011
2024
  }
2012
- adapterContextToken = guid();
2025
+ const adapterContextToken = guid();
2013
2026
  AdapterToTokenMap.set(adapter, adapterContextToken);
2014
2027
  const providers = new WeakSet();
2015
2028
  return (elmOrComponent, options) => {
@@ -4241,7 +4254,7 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4241
4254
  // compatibility, we lower case the tagname here.
4242
4255
  const normalizedTagname = sel.toLowerCase();
4243
4256
  const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
4244
- const isFormAssociated = Boolean(ctor.formAssociated);
4257
+ const isFormAssociated = shouldBeFormAssociated(ctor);
4245
4258
  const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle, isFormAssociated);
4246
4259
  vnode.elm = elm;
4247
4260
  vnode.vm = vm;
@@ -6971,7 +6984,8 @@ function hydrateCustomElement(elm, vnode, renderer) {
6971
6984
  }
6972
6985
  const { sel, mode, ctor, owner } = vnode;
6973
6986
  const { defineCustomElement, getTagName } = renderer;
6974
- defineCustomElement(shared.StringToLowerCase.call(getTagName(elm)), Boolean(ctor.formAssociated));
6987
+ const isFormAssociated = shouldBeFormAssociated(ctor);
6988
+ defineCustomElement(shared.StringToLowerCase.call(getTagName(elm)), isFormAssociated);
6975
6989
  const vm = createVM(elm, ctor, renderer, {
6976
6990
  mode,
6977
6991
  owner,
@@ -7585,11 +7599,12 @@ exports.runFormResetCallback = runFormResetCallback;
7585
7599
  exports.runFormStateRestoreCallback = runFormStateRestoreCallback;
7586
7600
  exports.sanitizeAttribute = sanitizeAttribute;
7587
7601
  exports.setHooks = setHooks;
7602
+ exports.shouldBeFormAssociated = shouldBeFormAssociated;
7588
7603
  exports.swapComponent = swapComponent;
7589
7604
  exports.swapStyle = swapStyle;
7590
7605
  exports.swapTemplate = swapTemplate;
7591
7606
  exports.track = track;
7592
7607
  exports.unwrap = unwrap;
7593
7608
  exports.wire = wire;
7594
- /** version: 6.3.1 */
7609
+ /** version: 6.3.2 */
7595
7610
  //# sourceMappingURL=index.cjs.js.map