@lwc/engine-core 6.3.0 → 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.
- package/dist/framework/main.d.ts +3 -1
- package/dist/framework/renderer.d.ts +2 -2
- package/dist/framework/utils.d.ts +1 -0
- package/dist/index.cjs.js +29 -92
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +30 -94
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2024 Salesforce, Inc.
|
|
3
3
|
*/
|
|
4
|
-
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, isFalse, isFunction as isFunction$1, isObject, seal, isAPIFeatureEnabled, isArray as isArray$1, keys, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, KEY__SYNTHETIC_MODE,
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, isFalse, isFunction as isFunction$1, isObject, seal, isAPIFeatureEnabled, isArray as isArray$1, keys, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, ArrayShift, ArrayUnshift, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse } from '@lwc/shared';
|
|
5
5
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
6
6
|
|
|
7
7
|
/*
|
|
@@ -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.
|
|
@@ -1663,79 +1675,6 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
|
1663
1675
|
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.`);
|
|
1664
1676
|
}
|
|
1665
1677
|
}
|
|
1666
|
-
// List of properties on ElementInternals that are formAssociated can be found in the spec:
|
|
1667
|
-
// https://html.spec.whatwg.org/multipage/custom-elements.html#form-associated-custom-elements
|
|
1668
|
-
const formAssociatedProps = new Set([
|
|
1669
|
-
'setFormValue',
|
|
1670
|
-
'form',
|
|
1671
|
-
'setValidity',
|
|
1672
|
-
'willValidate',
|
|
1673
|
-
'validity',
|
|
1674
|
-
'validationMessage',
|
|
1675
|
-
'checkValidity',
|
|
1676
|
-
'reportValidity',
|
|
1677
|
-
'labels',
|
|
1678
|
-
]);
|
|
1679
|
-
// Verify that access to a form-associated property of the ElementInternals proxy has formAssociated set in the LWC.
|
|
1680
|
-
function verifyPropForFormAssociation(propertyKey, isFormAssociated) {
|
|
1681
|
-
if (isString(propertyKey) && formAssociatedProps.has(propertyKey) && !isFormAssociated) {
|
|
1682
|
-
//Note this error message mirrors Chrome and Firefox error messages, in Safari the error is slightly different.
|
|
1683
|
-
throw new DOMException(`Failed to execute '${propertyKey}' on 'ElementInternals': The target element is not a form-associated custom element.`);
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
const elementInternalsAccessorAllowList = new Set(['shadowRoot', 'role', ...formAssociatedProps]);
|
|
1687
|
-
// Prevent access to properties not defined in the HTML spec in case browsers decide to
|
|
1688
|
-
// provide new APIs that provide access to form associated properties.
|
|
1689
|
-
// This can be removed along with UpgradeableConstructor.
|
|
1690
|
-
function isAllowedElementInternalAccessor(propertyKey) {
|
|
1691
|
-
let isAllowedAccessor = false;
|
|
1692
|
-
// As of this writing all ElementInternal property keys as described in the spec are implemented with strings
|
|
1693
|
-
// in Chrome, Firefox, and Safari
|
|
1694
|
-
if (isString(propertyKey)) {
|
|
1695
|
-
// Allow list is based on HTML spec:
|
|
1696
|
-
// https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface
|
|
1697
|
-
isAllowedAccessor =
|
|
1698
|
-
elementInternalsAccessorAllowList.has(propertyKey) || /^aria/.test(propertyKey);
|
|
1699
|
-
if (!isAllowedAccessor && process.env.NODE_ENV !== 'production') {
|
|
1700
|
-
logWarn('Only properties defined in the ElementInternals HTML spec are available.');
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
return isAllowedAccessor;
|
|
1704
|
-
}
|
|
1705
|
-
// Wrap all ElementInternal objects in a proxy to prevent form association when `formAssociated` is not set on an LWC.
|
|
1706
|
-
// This is needed because the 1UpgradeableConstructor1 always sets `formAssociated=true`, which means all
|
|
1707
|
-
// ElementInternal objects will have form-associated properties set when an LWC is placed in a form.
|
|
1708
|
-
// We are doing this to guard against customers taking a dependency on form elements being associated to ElementInternals
|
|
1709
|
-
// when 'formAssociated' has not been set on the LWC.
|
|
1710
|
-
function createElementInternalsProxy(elementInternals, isFormAssociated) {
|
|
1711
|
-
const elementInternalsProxy = new Proxy(elementInternals, {
|
|
1712
|
-
set(target, propertyKey, newValue) {
|
|
1713
|
-
if (isAllowedElementInternalAccessor(propertyKey)) {
|
|
1714
|
-
// Verify that formAssociated is set for form associated properties
|
|
1715
|
-
verifyPropForFormAssociation(propertyKey, isFormAssociated);
|
|
1716
|
-
return Reflect.set(target, propertyKey, newValue);
|
|
1717
|
-
}
|
|
1718
|
-
// As of this writing ElementInternals do not have non-string properties that can be set.
|
|
1719
|
-
return false;
|
|
1720
|
-
},
|
|
1721
|
-
get(target, propertyKey) {
|
|
1722
|
-
if (
|
|
1723
|
-
// Pass through Object.prototype methods such as toString()
|
|
1724
|
-
hasOwnProperty$1.call(Object.prototype, propertyKey) ||
|
|
1725
|
-
// As of this writing, ElementInternals only uses Symbol.toStringTag which is called
|
|
1726
|
-
// on Object.hasOwnProperty invocations
|
|
1727
|
-
Symbol.for('Symbol.toStringTag') === propertyKey ||
|
|
1728
|
-
// ElementInternals allow listed properties
|
|
1729
|
-
isAllowedElementInternalAccessor(propertyKey)) {
|
|
1730
|
-
// Verify that formAssociated is set for form associated properties
|
|
1731
|
-
verifyPropForFormAssociation(propertyKey, isFormAssociated);
|
|
1732
|
-
const propertyValue = Reflect.get(target, propertyKey);
|
|
1733
|
-
return isFunction$1(propertyValue) ? propertyValue.bind(target) : propertyValue;
|
|
1734
|
-
}
|
|
1735
|
-
},
|
|
1736
|
-
});
|
|
1737
|
-
return elementInternalsProxy;
|
|
1738
|
-
}
|
|
1739
1678
|
// Type assertion because we need to build the prototype before it satisfies the interface.
|
|
1740
1679
|
LightningElement.prototype = {
|
|
1741
1680
|
constructor: LightningElement,
|
|
@@ -1829,13 +1768,16 @@ LightningElement.prototype = {
|
|
|
1829
1768
|
},
|
|
1830
1769
|
attachInternals() {
|
|
1831
1770
|
const vm = getAssociatedVM(this);
|
|
1832
|
-
const { elm,
|
|
1771
|
+
const { elm, apiVersion, renderer: { attachInternals }, } = vm;
|
|
1772
|
+
if (!isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
|
|
1773
|
+
throw new Error(`The attachInternals API is only supported in API version 61 and above. ` +
|
|
1774
|
+
`The current version is ${apiVersion}. ` +
|
|
1775
|
+
`To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`);
|
|
1776
|
+
}
|
|
1833
1777
|
if (vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
1834
|
-
throw new Error('attachInternals API is not supported in
|
|
1778
|
+
throw new Error('attachInternals API is not supported in synthetic shadow.');
|
|
1835
1779
|
}
|
|
1836
|
-
|
|
1837
|
-
// #TODO[2970]: remove proxy once `UpgradeableConstructor` has been removed
|
|
1838
|
-
return createElementInternalsProxy(internals, Boolean(formAssociated));
|
|
1780
|
+
return attachInternals(elm);
|
|
1839
1781
|
},
|
|
1840
1782
|
get isConnected() {
|
|
1841
1783
|
const vm = getAssociatedVM(this);
|
|
@@ -2073,11 +2015,10 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
2073
2015
|
*/
|
|
2074
2016
|
const AdapterToTokenMap = new Map();
|
|
2075
2017
|
function createContextProviderWithRegister(adapter, registerContextProvider) {
|
|
2076
|
-
|
|
2077
|
-
if (!isUndefined$1(adapterContextToken)) {
|
|
2018
|
+
if (AdapterToTokenMap.has(adapter)) {
|
|
2078
2019
|
throw new Error(`Adapter already has a context provider.`);
|
|
2079
2020
|
}
|
|
2080
|
-
adapterContextToken = guid();
|
|
2021
|
+
const adapterContextToken = guid();
|
|
2081
2022
|
AdapterToTokenMap.set(adapter, adapterContextToken);
|
|
2082
2023
|
const providers = new WeakSet();
|
|
2083
2024
|
return (elmOrComponent, options) => {
|
|
@@ -4309,7 +4250,8 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
4309
4250
|
// compatibility, we lower case the tagname here.
|
|
4310
4251
|
const normalizedTagname = sel.toLowerCase();
|
|
4311
4252
|
const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
|
|
4312
|
-
const
|
|
4253
|
+
const isFormAssociated = shouldBeFormAssociated(ctor);
|
|
4254
|
+
const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle, isFormAssociated);
|
|
4313
4255
|
vnode.elm = elm;
|
|
4314
4256
|
vnode.vm = vm;
|
|
4315
4257
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -6545,14 +6487,7 @@ function forceRehydration(vm) {
|
|
|
6545
6487
|
}
|
|
6546
6488
|
}
|
|
6547
6489
|
function runFormAssociatedCustomElementCallback(vm, faceCb) {
|
|
6548
|
-
const { renderMode, shadowMode
|
|
6549
|
-
// Technically the UpgradableConstructor always sets `static formAssociated = true` but silently fail here to match browser behavior.
|
|
6550
|
-
if (isUndefined$1(formAssociated) || isFalse(formAssociated)) {
|
|
6551
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6552
|
-
logWarn(`Form associated lifecycle methods must have the 'static formAssociated' value set in the component's prototype chain.`);
|
|
6553
|
-
}
|
|
6554
|
-
return;
|
|
6555
|
-
}
|
|
6490
|
+
const { renderMode, shadowMode } = vm;
|
|
6556
6491
|
if (shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode !== 0 /* RenderMode.Light */) {
|
|
6557
6492
|
throw new Error('Form associated lifecycle methods are not available in synthetic shadow. Please use native shadow or light DOM.');
|
|
6558
6493
|
}
|
|
@@ -7045,7 +6980,8 @@ function hydrateCustomElement(elm, vnode, renderer) {
|
|
|
7045
6980
|
}
|
|
7046
6981
|
const { sel, mode, ctor, owner } = vnode;
|
|
7047
6982
|
const { defineCustomElement, getTagName } = renderer;
|
|
7048
|
-
|
|
6983
|
+
const isFormAssociated = shouldBeFormAssociated(ctor);
|
|
6984
|
+
defineCustomElement(StringToLowerCase.call(getTagName(elm)), isFormAssociated);
|
|
7049
6985
|
const vm = createVM(elm, ctor, renderer, {
|
|
7050
6986
|
mode,
|
|
7051
6987
|
owner,
|
|
@@ -7622,6 +7558,6 @@ function readonly(obj) {
|
|
|
7622
7558
|
return getReadOnlyProxy(obj);
|
|
7623
7559
|
}
|
|
7624
7560
|
|
|
7625
|
-
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 };
|
|
7626
|
-
/** version: 6.3.
|
|
7561
|
+
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 };
|
|
7562
|
+
/** version: 6.3.2 */
|
|
7627
7563
|
//# sourceMappingURL=index.js.map
|