@lwc/engine-core 5.0.6 → 5.0.8
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/index.cjs.js +69 -57
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +70 -58
- package/dist/index.js.map +1 -1
- package/dist/libs/aria-reflection/aria-reflection.d.ts +1 -2
- package/package.json +3 -3
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, AriaPropNameToAttrNameMap,
|
|
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, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, freeze, KEY__SYNTHETIC_MODE, isString, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$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';
|
|
5
5
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
6
6
|
|
|
7
7
|
/*
|
|
@@ -421,54 +421,53 @@ const instrumentDef = (_a = globalThis$1.__lwc_instrument_cmp_def) !== null && _
|
|
|
421
421
|
const instrumentInstance = (_b = globalThis$1.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
|
|
422
422
|
|
|
423
423
|
/*
|
|
424
|
-
* Copyright (c)
|
|
424
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
425
425
|
* All rights reserved.
|
|
426
426
|
* SPDX-License-Identifier: MIT
|
|
427
427
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
428
428
|
*/
|
|
429
|
-
//
|
|
430
|
-
//
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
function applyAriaReflection(prototype) {
|
|
434
|
-
for (const propName of keys(AriaPropNameToAttrNameMap)) {
|
|
435
|
-
const attrName = AriaPropNameToAttrNameMap[propName];
|
|
436
|
-
if (isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName))) {
|
|
437
|
-
// Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
|
|
438
|
-
// from Element.prototype, because these methods are overridden in LightningElement.
|
|
439
|
-
defineProperty(prototype, propName, {
|
|
440
|
-
get() {
|
|
441
|
-
return this.getAttribute(attrName);
|
|
442
|
-
},
|
|
443
|
-
set(newValue) {
|
|
444
|
-
// TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
|
|
445
|
-
// Our historical behavior is to only treat null as removing the attribute
|
|
446
|
-
// See also https://github.com/w3c/aria/issues/1858
|
|
447
|
-
if (isNull(newValue)) {
|
|
448
|
-
this.removeAttribute(attrName);
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
this.setAttribute(attrName, newValue);
|
|
452
|
-
}
|
|
453
|
-
},
|
|
454
|
-
// configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
|
|
455
|
-
configurable: true,
|
|
456
|
-
enumerable: true,
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
429
|
+
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
430
|
+
// to inject at runtime.
|
|
431
|
+
const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
|
|
432
|
+
const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
|
461
433
|
|
|
462
434
|
/*
|
|
463
|
-
* Copyright (c)
|
|
435
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
464
436
|
* All rights reserved.
|
|
465
437
|
* SPDX-License-Identifier: MIT
|
|
466
438
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
467
439
|
*/
|
|
468
|
-
//
|
|
469
|
-
//
|
|
470
|
-
|
|
471
|
-
|
|
440
|
+
// Apply ARIA string reflection behavior to a prototype.
|
|
441
|
+
// This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
|
|
442
|
+
// needed for backwards compatibility in LEX, whereas this is designed to only apply to our own
|
|
443
|
+
// LightningElement/BaseBridgeElement prototypes.
|
|
444
|
+
// Note we only need to handle ARIA reflections that aren't already in Element.prototype
|
|
445
|
+
const ariaReflectionPolyfillDescriptors = create(null);
|
|
446
|
+
for (const [propName, attrName] of entries(AriaPropNameToAttrNameMap)) {
|
|
447
|
+
if (isUndefined$1(getPropertyDescriptor(HTMLElementPrototype, propName))) {
|
|
448
|
+
// Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
|
|
449
|
+
// from Element.prototype, because these methods are overridden in LightningElement.
|
|
450
|
+
ariaReflectionPolyfillDescriptors[propName] = {
|
|
451
|
+
get() {
|
|
452
|
+
return this.getAttribute(attrName);
|
|
453
|
+
},
|
|
454
|
+
set(newValue) {
|
|
455
|
+
// TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
|
|
456
|
+
// Our historical behavior is to only treat null as removing the attribute
|
|
457
|
+
// See also https://github.com/w3c/aria/issues/1858
|
|
458
|
+
if (isNull(newValue)) {
|
|
459
|
+
this.removeAttribute(attrName);
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
this.setAttribute(attrName, newValue);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
// configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
|
|
466
|
+
configurable: true,
|
|
467
|
+
enumerable: true,
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
472
471
|
|
|
473
472
|
/*
|
|
474
473
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1842,11 +1841,22 @@ const lightningBasedDescriptors = create(null);
|
|
|
1842
1841
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
1843
1842
|
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
1844
1843
|
}
|
|
1845
|
-
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
1846
1844
|
// Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
|
|
1847
1845
|
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
1848
1846
|
// Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
|
|
1849
|
-
|
|
1847
|
+
if (process.env.IS_BROWSER) {
|
|
1848
|
+
// In the browser, we use createBridgeToElementDescriptor, so we can get the normal reactivity lifecycle for
|
|
1849
|
+
// aria* properties
|
|
1850
|
+
for (const [propName, descriptor] of entries(ariaReflectionPolyfillDescriptors)) {
|
|
1851
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, descriptor);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
// On the server, we cannot use createBridgeToElementDescriptor because getAttribute/setAttribute are
|
|
1856
|
+
// not supported on HTMLElement. So apply the polyfill directly on top of LightningElement
|
|
1857
|
+
defineProperties(LightningElement.prototype, ariaReflectionPolyfillDescriptors);
|
|
1858
|
+
}
|
|
1859
|
+
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
1850
1860
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
1851
1861
|
get() {
|
|
1852
1862
|
// If required, a runtime-specific implementation must be defined.
|
|
@@ -2696,7 +2706,8 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
|
|
|
2696
2706
|
// and can break tooling that expects it to be iterable or defined, e.g. Jest:
|
|
2697
2707
|
// https://github.com/jestjs/jest/blob/b4c9587/packages/pretty-format/src/plugins/DOMElement.ts#L95
|
|
2698
2708
|
// It also doesn't make sense to override e.g. "constructor".
|
|
2699
|
-
.filter((propName) => !(propName in HTMLElementPrototype)
|
|
2709
|
+
.filter((propName) => !(propName in HTMLElementPrototype) &&
|
|
2710
|
+
!(propName in ariaReflectionPolyfillDescriptors)));
|
|
2700
2711
|
for (const propName of nonPublicPropertiesToWarnOn) {
|
|
2701
2712
|
if (ArrayIndexOf.call(publicProperties, propName) === -1) {
|
|
2702
2713
|
descriptors[propName] = createAccessorThatWarns(propName);
|
|
@@ -2766,21 +2777,22 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
|
|
|
2766
2777
|
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
2767
2778
|
return HTMLBridgeElement;
|
|
2768
2779
|
}
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2780
|
+
// We do some special handling of non-standard ARIA props like ariaLabelledBy as well as props without (as of this
|
|
2781
|
+
// writing) broad cross-browser support like ariaBrailleLabel. This is so the reflection works correctly and preserves
|
|
2782
|
+
// backwards compatibility with the previous global polyfill approach.
|
|
2783
|
+
//
|
|
2784
|
+
// The goal here is to expose `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*`
|
|
2785
|
+
// attrs. This is especially important because the template compiler compiles aria-* attrs on components to aria* props.
|
|
2786
|
+
// Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
|
|
2787
|
+
//
|
|
2788
|
+
// Also note this ARIA reflection only really makes sense in the browser. On the server, there is no
|
|
2789
|
+
// `renderedCallback()`, so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't
|
|
2790
|
+
// need to expose ARIA props outside the LightningElement
|
|
2791
|
+
const basePublicProperties = [
|
|
2792
|
+
...getOwnPropertyNames$1(HTMLElementOriginalDescriptors),
|
|
2793
|
+
...(process.env.IS_BROWSER ? getOwnPropertyNames$1(ariaReflectionPolyfillDescriptors) : []),
|
|
2794
|
+
];
|
|
2795
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, basePublicProperties, [], [], null, false);
|
|
2784
2796
|
freeze(BaseBridgeElement);
|
|
2785
2797
|
seal(BaseBridgeElement.prototype);
|
|
2786
2798
|
|
|
@@ -7313,5 +7325,5 @@ function readonly(obj) {
|
|
|
7313
7325
|
}
|
|
7314
7326
|
|
|
7315
7327
|
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 };
|
|
7316
|
-
/** version: 5.0.
|
|
7328
|
+
/** version: 5.0.8 */
|
|
7317
7329
|
//# sourceMappingURL=index.js.map
|