@lwc/engine-core 5.2.1 → 5.3.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/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.
|
|
@@ -1918,11 +1917,22 @@ const lightningBasedDescriptors = create(null);
|
|
|
1918
1917
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
1919
1918
|
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
1920
1919
|
}
|
|
1921
|
-
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
1922
1920
|
// Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
|
|
1923
1921
|
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
1924
1922
|
// Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
|
|
1925
|
-
|
|
1923
|
+
if (process.env.IS_BROWSER) {
|
|
1924
|
+
// In the browser, we use createBridgeToElementDescriptor, so we can get the normal reactivity lifecycle for
|
|
1925
|
+
// aria* properties
|
|
1926
|
+
for (const [propName, descriptor] of entries(ariaReflectionPolyfillDescriptors)) {
|
|
1927
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, descriptor);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
else {
|
|
1931
|
+
// On the server, we cannot use createBridgeToElementDescriptor because getAttribute/setAttribute are
|
|
1932
|
+
// not supported on HTMLElement. So apply the polyfill directly on top of LightningElement
|
|
1933
|
+
defineProperties(LightningElement.prototype, ariaReflectionPolyfillDescriptors);
|
|
1934
|
+
}
|
|
1935
|
+
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
1926
1936
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
1927
1937
|
get() {
|
|
1928
1938
|
// If required, a runtime-specific implementation must be defined.
|
|
@@ -2772,7 +2782,8 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
|
|
|
2772
2782
|
// and can break tooling that expects it to be iterable or defined, e.g. Jest:
|
|
2773
2783
|
// https://github.com/jestjs/jest/blob/b4c9587/packages/pretty-format/src/plugins/DOMElement.ts#L95
|
|
2774
2784
|
// It also doesn't make sense to override e.g. "constructor".
|
|
2775
|
-
.filter((propName) => !(propName in HTMLElementPrototype)
|
|
2785
|
+
.filter((propName) => !(propName in HTMLElementPrototype) &&
|
|
2786
|
+
!(propName in ariaReflectionPolyfillDescriptors)));
|
|
2776
2787
|
for (const propName of nonPublicPropertiesToWarnOn) {
|
|
2777
2788
|
if (ArrayIndexOf.call(publicProperties, propName) === -1) {
|
|
2778
2789
|
descriptors[propName] = createAccessorThatWarns(propName);
|
|
@@ -2842,21 +2853,22 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
|
|
|
2842
2853
|
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
2843
2854
|
return HTMLBridgeElement;
|
|
2844
2855
|
}
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2856
|
+
// We do some special handling of non-standard ARIA props like ariaLabelledBy as well as props without (as of this
|
|
2857
|
+
// writing) broad cross-browser support like ariaBrailleLabel. This is so the reflection works correctly and preserves
|
|
2858
|
+
// backwards compatibility with the previous global polyfill approach.
|
|
2859
|
+
//
|
|
2860
|
+
// The goal here is to expose `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*`
|
|
2861
|
+
// attrs. This is especially important because the template compiler compiles aria-* attrs on components to aria* props.
|
|
2862
|
+
// Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
|
|
2863
|
+
//
|
|
2864
|
+
// Also note this ARIA reflection only really makes sense in the browser. On the server, there is no
|
|
2865
|
+
// `renderedCallback()`, so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't
|
|
2866
|
+
// need to expose ARIA props outside the LightningElement
|
|
2867
|
+
const basePublicProperties = [
|
|
2868
|
+
...getOwnPropertyNames$1(HTMLElementOriginalDescriptors),
|
|
2869
|
+
...(process.env.IS_BROWSER ? getOwnPropertyNames$1(ariaReflectionPolyfillDescriptors) : []),
|
|
2870
|
+
];
|
|
2871
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, basePublicProperties, [], [], null, false);
|
|
2860
2872
|
freeze(BaseBridgeElement);
|
|
2861
2873
|
seal(BaseBridgeElement.prototype);
|
|
2862
2874
|
|
|
@@ -7372,5 +7384,5 @@ function readonly(obj) {
|
|
|
7372
7384
|
}
|
|
7373
7385
|
|
|
7374
7386
|
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 };
|
|
7375
|
-
/** version: 5.
|
|
7387
|
+
/** version: 5.3.0 */
|
|
7376
7388
|
//# sourceMappingURL=index.js.map
|