@lwc/engine-core 3.8.0 → 4.0.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/api.d.ts +2 -2
- package/dist/framework/vm.d.ts +5 -0
- package/dist/index.cjs.js +102 -60
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +103 -61
- package/dist/index.js.map +1 -1
- package/dist/libs/aria-reflection/aria-reflection.d.ts +2 -0
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -1,8 +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,
|
|
5
|
-
import { applyAriaReflection } from '@lwc/aria-reflection';
|
|
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, AriaPropNameToAttrNameMap, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, forEach, getPropertyDescriptor, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, freeze, KEY__SYNTHETIC_MODE, isString, assert, toString as toString$1, isFalse, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, ArrayShift, ArrayUnshift, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isAPIFeatureEnabled, 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';
|
|
6
5
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
7
6
|
|
|
8
7
|
/*
|
|
@@ -415,6 +414,45 @@ var _a, _b;
|
|
|
415
414
|
const instrumentDef = (_a = globalThis$1.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : noop;
|
|
416
415
|
const instrumentInstance = (_b = globalThis$1.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
|
|
417
416
|
|
|
417
|
+
/*
|
|
418
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
419
|
+
* All rights reserved.
|
|
420
|
+
* SPDX-License-Identifier: MIT
|
|
421
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
422
|
+
*/
|
|
423
|
+
// Apply ARIA string reflection behavior to a prototype.
|
|
424
|
+
// This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
|
|
425
|
+
// needed for backwards compatibility in LEX, whereas `applyAriaReflection` is designed to only apply to our own
|
|
426
|
+
// LightningElement/BaseBridgeElement prototypes.
|
|
427
|
+
function applyAriaReflection(prototype) {
|
|
428
|
+
for (const propName of keys(AriaPropNameToAttrNameMap)) {
|
|
429
|
+
const attrName = AriaPropNameToAttrNameMap[propName];
|
|
430
|
+
if (isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName))) {
|
|
431
|
+
// Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
|
|
432
|
+
// from Element.prototype, because these methods are overridden in LightningElement.
|
|
433
|
+
defineProperty(prototype, propName, {
|
|
434
|
+
get() {
|
|
435
|
+
return this.getAttribute(attrName);
|
|
436
|
+
},
|
|
437
|
+
set(newValue) {
|
|
438
|
+
// TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
|
|
439
|
+
// Our historical behavior is to only treat null as removing the attribute
|
|
440
|
+
// See also https://github.com/w3c/aria/issues/1858
|
|
441
|
+
if (isNull(newValue)) {
|
|
442
|
+
this.removeAttribute(attrName);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
this.setAttribute(attrName, newValue);
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
// configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
|
|
449
|
+
configurable: true,
|
|
450
|
+
enumerable: true,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
418
456
|
/*
|
|
419
457
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
420
458
|
* All rights reserved.
|
|
@@ -1799,15 +1837,10 @@ for (const propName in HTMLElementOriginalDescriptors) {
|
|
|
1799
1837
|
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
1800
1838
|
}
|
|
1801
1839
|
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
applyAriaReflection(LightningElement.prototype);
|
|
1807
|
-
}
|
|
1808
|
-
if (!process.env.IS_BROWSER || lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
1809
|
-
applyAriaReflectionToLightningElement();
|
|
1810
|
-
}
|
|
1840
|
+
// Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
|
|
1841
|
+
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
1842
|
+
// Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
|
|
1843
|
+
applyAriaReflection(LightningElement.prototype);
|
|
1811
1844
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
1812
1845
|
get() {
|
|
1813
1846
|
// If required, a runtime-specific implementation must be defined.
|
|
@@ -2732,15 +2765,15 @@ if (process.env.IS_BROWSER) {
|
|
|
2732
2765
|
// This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
|
|
2733
2766
|
// so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
|
|
2734
2767
|
// ARIA props outside the LightningElement
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2768
|
+
//
|
|
2769
|
+
// Apply ARIA reflection to HTMLBridgeElement.prototype. This allows `elm.aria*` property accessors to work from
|
|
2770
|
+
// outside a component, and to reflect `aria-*` attrs. This is especially important because the template compiler
|
|
2771
|
+
// compiles aria-* attrs on components to aria* props.
|
|
2772
|
+
// Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
|
|
2773
|
+
//
|
|
2774
|
+
// Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
|
|
2775
|
+
// accessors inside the HTMLBridgeElementFactory.
|
|
2776
|
+
applyAriaReflection(BaseBridgeElement.prototype);
|
|
2744
2777
|
}
|
|
2745
2778
|
freeze(BaseBridgeElement);
|
|
2746
2779
|
seal(BaseBridgeElement.prototype);
|
|
@@ -4792,10 +4825,16 @@ function s(slotName, data, children, slotset) {
|
|
|
4792
4825
|
children = newChildren;
|
|
4793
4826
|
}
|
|
4794
4827
|
const vmBeingRendered = getVMBeingRendered();
|
|
4795
|
-
const { renderMode, shadowMode } = vmBeingRendered;
|
|
4828
|
+
const { renderMode, shadowMode, apiVersion } = vmBeingRendered;
|
|
4796
4829
|
if (renderMode === 0 /* RenderMode.Light */) {
|
|
4797
|
-
|
|
4798
|
-
|
|
4830
|
+
// light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
|
|
4831
|
+
if (isAPIFeatureEnabled(2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */, apiVersion)) {
|
|
4832
|
+
return fr(data.key, children, 0);
|
|
4833
|
+
}
|
|
4834
|
+
else {
|
|
4835
|
+
sc(children);
|
|
4836
|
+
return children;
|
|
4837
|
+
}
|
|
4799
4838
|
}
|
|
4800
4839
|
if (shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
4801
4840
|
// TODO [#1276]: compiler should give us some sort of indicator when a vnodes collection is dynamic
|
|
@@ -5706,6 +5745,7 @@ function getNearestShadowAncestor(owner) {
|
|
|
5706
5745
|
function createVM(elm, ctor, renderer, options) {
|
|
5707
5746
|
const { mode, owner, tagName, hydrated } = options;
|
|
5708
5747
|
const def = getComponentInternalDef(ctor);
|
|
5748
|
+
const apiVersion = getComponentAPIVersion(ctor);
|
|
5709
5749
|
const vm = {
|
|
5710
5750
|
elm,
|
|
5711
5751
|
def,
|
|
@@ -5751,6 +5791,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5751
5791
|
setHook,
|
|
5752
5792
|
getHook,
|
|
5753
5793
|
renderer,
|
|
5794
|
+
apiVersion,
|
|
5754
5795
|
};
|
|
5755
5796
|
if (process.env.NODE_ENV !== 'production') {
|
|
5756
5797
|
vm.debugInfo = create(null);
|
|
@@ -6386,10 +6427,11 @@ const NON_STANDARD_ARIA_PROPS = [
|
|
|
6386
6427
|
'ariaLabelledBy',
|
|
6387
6428
|
'ariaOwns',
|
|
6388
6429
|
];
|
|
6389
|
-
function
|
|
6390
|
-
//
|
|
6391
|
-
//
|
|
6392
|
-
|
|
6430
|
+
function isGlobalAriaPolyfillLoaded() {
|
|
6431
|
+
// Sniff for the legacy polyfill being loaded. The reason this works is because ariaActiveDescendant is a
|
|
6432
|
+
// non-standard ARIA property reflection that is only supported in our legacy polyfill. See
|
|
6433
|
+
// @lwc/aria-reflection/README.md for details.
|
|
6434
|
+
return !isUndefined$1(getOwnPropertyDescriptor$1(Element.prototype, 'ariaActiveDescendant'));
|
|
6393
6435
|
}
|
|
6394
6436
|
function findVM(elm) {
|
|
6395
6437
|
// If it's a shadow DOM component, then it has a host
|
|
@@ -6401,7 +6443,8 @@ function findVM(elm) {
|
|
|
6401
6443
|
// Else it might be a light DOM component. Walk up the tree trying to find the owner
|
|
6402
6444
|
let parentElement = elm;
|
|
6403
6445
|
while (!isNull((parentElement = parentElement.parentElement))) {
|
|
6404
|
-
if (
|
|
6446
|
+
if (parentElement instanceof BaseBridgeElement) {
|
|
6447
|
+
// parentElement is an LWC component
|
|
6405
6448
|
const vm = getAssociatedVMIfPresent(parentElement);
|
|
6406
6449
|
if (!isUndefined$1(vm)) {
|
|
6407
6450
|
return vm;
|
|
@@ -6411,28 +6454,26 @@ function findVM(elm) {
|
|
|
6411
6454
|
// If we return undefined, it's because the element was rendered wholly outside a LightningElement
|
|
6412
6455
|
}
|
|
6413
6456
|
function checkAndReportViolation(elm, prop, isSetter, setValue) {
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
});
|
|
6435
|
-
}
|
|
6457
|
+
const vm = findVM(elm);
|
|
6458
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6459
|
+
logWarnOnce(`Element <${elm.tagName.toLowerCase()}> ` +
|
|
6460
|
+
(isUndefined$1(vm) ? '' : `owned by <${vm.elm.tagName.toLowerCase()}> `) +
|
|
6461
|
+
`uses non-standard property "${prop}". This will be removed in a future version of LWC. ` +
|
|
6462
|
+
`See https://sfdc.co/deprecated-aria`);
|
|
6463
|
+
}
|
|
6464
|
+
let setValueType;
|
|
6465
|
+
if (isSetter) {
|
|
6466
|
+
// `typeof null` is "object" which is not very useful for detecting null.
|
|
6467
|
+
// We mostly want to know null vs undefined vs other types here, due to
|
|
6468
|
+
// https://github.com/salesforce/lwc/issues/3284
|
|
6469
|
+
setValueType = isNull(setValue) ? 'null' : typeof setValue;
|
|
6470
|
+
}
|
|
6471
|
+
report("NonStandardAriaReflection" /* ReportingEventId.NonStandardAriaReflection */, {
|
|
6472
|
+
tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
|
|
6473
|
+
propertyName: prop,
|
|
6474
|
+
isSetter,
|
|
6475
|
+
setValueType,
|
|
6476
|
+
});
|
|
6436
6477
|
}
|
|
6437
6478
|
function enableDetection() {
|
|
6438
6479
|
const { prototype } = Element;
|
|
@@ -6451,6 +6492,9 @@ function enableDetection() {
|
|
|
6451
6492
|
}
|
|
6452
6493
|
// @ts-ignore
|
|
6453
6494
|
const { get, set } = descriptor;
|
|
6495
|
+
// It's important for this defineProperty call to happen _after_ ARIA accessors are applied to the
|
|
6496
|
+
// BaseBridgeElement and LightningElement prototypes. Otherwise, we will log/report for access of non-standard
|
|
6497
|
+
// props on these prototypes, which we actually don't want. We only care about access on generic HTMLElements.
|
|
6454
6498
|
defineProperty(prototype, prop, {
|
|
6455
6499
|
get() {
|
|
6456
6500
|
checkAndReportViolation(this, prop, false, undefined);
|
|
@@ -6466,16 +6510,14 @@ function enableDetection() {
|
|
|
6466
6510
|
}
|
|
6467
6511
|
}
|
|
6468
6512
|
// No point in running this code if we're not in a browser, or if the global polyfill is not loaded
|
|
6469
|
-
if (process.env.IS_BROWSER) {
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
onReportingEnabled(enableDetection);
|
|
6478
|
-
}
|
|
6513
|
+
if (process.env.IS_BROWSER && isGlobalAriaPolyfillLoaded()) {
|
|
6514
|
+
// Always run detection in dev mode, so we can at least print to the console
|
|
6515
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6516
|
+
enableDetection();
|
|
6517
|
+
}
|
|
6518
|
+
else {
|
|
6519
|
+
// In prod mode, only enable detection if reporting is enabled
|
|
6520
|
+
onReportingEnabled(enableDetection);
|
|
6479
6521
|
}
|
|
6480
6522
|
}
|
|
6481
6523
|
|
|
@@ -7225,5 +7267,5 @@ function readonly(obj) {
|
|
|
7225
7267
|
}
|
|
7226
7268
|
|
|
7227
7269
|
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 };
|
|
7228
|
-
/** version:
|
|
7270
|
+
/** version: 4.0.0 */
|
|
7229
7271
|
//# sourceMappingURL=index.js.map
|