@lwc/engine-core 3.1.3 → 3.2.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.
- package/dist/framework/base-lightning-element.d.ts +1 -1
- package/dist/framework/main.d.ts +1 -1
- package/dist/framework/renderer.d.ts +1 -0
- package/dist/framework/vm.d.ts +4 -0
- package/dist/index.cjs.js +42 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
3
3
|
*/
|
|
4
|
-
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, globalThis as globalThis$1, forEach, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1,
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, globalThis as globalThis$1, forEach, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, isFalse, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, ArrayUnshift, 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, ArrayShift } from '@lwc/shared';
|
|
5
5
|
import { applyAriaReflection } from '@lwc/aria-reflection';
|
|
6
6
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
7
7
|
|
|
@@ -1454,6 +1454,7 @@ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
|
1454
1454
|
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.`);
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
|
+
const supportsElementInternals = typeof ElementInternals !== 'undefined';
|
|
1457
1458
|
// @ts-ignore
|
|
1458
1459
|
LightningElement.prototype = {
|
|
1459
1460
|
constructor: LightningElement,
|
|
@@ -1545,6 +1546,18 @@ LightningElement.prototype = {
|
|
|
1545
1546
|
}
|
|
1546
1547
|
return getBoundingClientRect(elm);
|
|
1547
1548
|
},
|
|
1549
|
+
attachInternals() {
|
|
1550
|
+
const vm = getAssociatedVM(this);
|
|
1551
|
+
const { elm, renderer: { attachInternals }, } = vm;
|
|
1552
|
+
if (isFalse(supportsElementInternals)) {
|
|
1553
|
+
// Browsers that don't support attachInternals will need to be polyfilled before LWC is loaded.
|
|
1554
|
+
throw new Error('attachInternals API is not supported in this browser environment.');
|
|
1555
|
+
}
|
|
1556
|
+
if (vm.renderMode === 0 /* RenderMode.Light */ || vm.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
1557
|
+
throw new Error('attachInternals API is not supported in light DOM or synthetic shadow.');
|
|
1558
|
+
}
|
|
1559
|
+
return attachInternals(elm);
|
|
1560
|
+
},
|
|
1548
1561
|
get isConnected() {
|
|
1549
1562
|
const vm = getAssociatedVM(this);
|
|
1550
1563
|
const { elm, renderer: { isConnected }, } = vm;
|
|
@@ -2586,6 +2599,14 @@ function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
|
2586
2599
|
descriptors.attributeChangedCallback = {
|
|
2587
2600
|
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback),
|
|
2588
2601
|
};
|
|
2602
|
+
// To avoid leaking private component details, accessing internals from outside a component is not allowed.
|
|
2603
|
+
descriptors.attachInternals = {
|
|
2604
|
+
get() {
|
|
2605
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2606
|
+
logError('attachInternals cannot be accessed outside of a component. Use this.attachInternals instead.');
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
};
|
|
2589
2610
|
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
2590
2611
|
// properties via attributeChangedCallback.
|
|
2591
2612
|
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
@@ -5411,8 +5432,8 @@ function removeVM(vm) {
|
|
|
5411
5432
|
}
|
|
5412
5433
|
resetComponentStateWhenRemoved(vm);
|
|
5413
5434
|
}
|
|
5414
|
-
function getNearestShadowAncestor(
|
|
5415
|
-
let ancestor =
|
|
5435
|
+
function getNearestShadowAncestor(owner) {
|
|
5436
|
+
let ancestor = owner;
|
|
5416
5437
|
while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5417
5438
|
ancestor = ancestor.owner;
|
|
5418
5439
|
}
|
|
@@ -5468,15 +5489,12 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5468
5489
|
vm.debugInfo = create(null);
|
|
5469
5490
|
}
|
|
5470
5491
|
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5471
|
-
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5492
|
+
vm.shadowMode = computeShadowMode(def, vm.owner, renderer);
|
|
5472
5493
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5473
5494
|
if (process.env.NODE_ENV !== 'production') {
|
|
5474
5495
|
vm.toString = () => {
|
|
5475
5496
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5476
5497
|
};
|
|
5477
|
-
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5478
|
-
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5479
|
-
}
|
|
5480
5498
|
}
|
|
5481
5499
|
// Create component instance associated to the vm and the element.
|
|
5482
5500
|
invokeComponentConstructor(vm, def.ctor);
|
|
@@ -5539,8 +5557,21 @@ function warnOnStylesheetsMutation(ctor) {
|
|
|
5539
5557
|
});
|
|
5540
5558
|
}
|
|
5541
5559
|
}
|
|
5542
|
-
|
|
5543
|
-
|
|
5560
|
+
// Compute the shadowMode/renderMode without creating a VM. This is used in some scenarios like hydration.
|
|
5561
|
+
function computeShadowAndRenderMode(Ctor, renderer) {
|
|
5562
|
+
const def = getComponentInternalDef(Ctor);
|
|
5563
|
+
const { renderMode } = def;
|
|
5564
|
+
// Assume null `owner` - this is what happens in hydration cases anyway
|
|
5565
|
+
const shadowMode = computeShadowMode(def, /* owner */ null, renderer);
|
|
5566
|
+
return { renderMode, shadowMode };
|
|
5567
|
+
}
|
|
5568
|
+
function computeShadowMode(def, owner, renderer) {
|
|
5569
|
+
// Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
|
|
5570
|
+
// on, but components running in actual native shadow mode
|
|
5571
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
5572
|
+
lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5573
|
+
return 0 /* ShadowMode.Native */;
|
|
5574
|
+
}
|
|
5544
5575
|
const { isSyntheticShadowDefined } = renderer;
|
|
5545
5576
|
let shadowMode;
|
|
5546
5577
|
if (isSyntheticShadowDefined) {
|
|
@@ -5554,7 +5585,7 @@ function computeShadowMode(vm, renderer) {
|
|
|
5554
5585
|
shadowMode = 0 /* ShadowMode.Native */;
|
|
5555
5586
|
}
|
|
5556
5587
|
else {
|
|
5557
|
-
const shadowAncestor = getNearestShadowAncestor(
|
|
5588
|
+
const shadowAncestor = getNearestShadowAncestor(owner);
|
|
5558
5589
|
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5559
5590
|
// Transitive support for native Shadow DOM. A component in native mode
|
|
5560
5591
|
// transitively opts all of its descendants into native.
|
|
@@ -6878,6 +6909,6 @@ function readonly(obj) {
|
|
|
6878
6909
|
return getReadOnlyProxy(obj);
|
|
6879
6910
|
}
|
|
6880
6911
|
|
|
6881
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6882
|
-
/** version: 3.
|
|
6912
|
+
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, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6913
|
+
/** version: 3.2.0 */
|
|
6883
6914
|
//# sourceMappingURL=index.js.map
|