@lwc/engine-core 5.0.4 → 5.0.6

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.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, 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';
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';
5
5
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
6
6
 
7
7
  /*
@@ -420,17 +420,6 @@ var _a, _b;
420
420
  const instrumentDef = (_a = globalThis$1.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : noop;
421
421
  const instrumentInstance = (_b = globalThis$1.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
422
422
 
423
- /*
424
- * Copyright (c) 2018, salesforce.com, inc.
425
- * All rights reserved.
426
- * SPDX-License-Identifier: MIT
427
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
428
- */
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;
433
-
434
423
  /*
435
424
  * Copyright (c) 2023, salesforce.com, inc.
436
425
  * All rights reserved.
@@ -439,36 +428,48 @@ const HTMLElementPrototype = HTMLElementConstructor.prototype;
439
428
  */
440
429
  // Apply ARIA string reflection behavior to a prototype.
441
430
  // 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
431
+ // needed for backwards compatibility in LEX, whereas `applyAriaReflection` is designed to only apply to our own
443
432
  // 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
- };
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
+ }
469
459
  }
470
460
  }
471
461
 
462
+ /*
463
+ * Copyright (c) 2018, salesforce.com, inc.
464
+ * All rights reserved.
465
+ * SPDX-License-Identifier: MIT
466
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
467
+ */
468
+ // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
469
+ // to inject at runtime.
470
+ const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
471
+ const HTMLElementPrototype = HTMLElementConstructor.prototype;
472
+
472
473
  /*
473
474
  * Copyright (c) 2018, salesforce.com, inc.
474
475
  * All rights reserved.
@@ -1841,22 +1842,11 @@ const lightningBasedDescriptors = create(null);
1841
1842
  for (const propName in HTMLElementOriginalDescriptors) {
1842
1843
  lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
1843
1844
  }
1845
+ defineProperties(LightningElement.prototype, lightningBasedDescriptors);
1844
1846
  // Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
1845
1847
  // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
1846
1848
  // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
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);
1849
+ applyAriaReflection(LightningElement.prototype);
1860
1850
  defineProperty(LightningElement, 'CustomElementConstructor', {
1861
1851
  get() {
1862
1852
  // If required, a runtime-specific implementation must be defined.
@@ -2706,8 +2696,7 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
2706
2696
  // and can break tooling that expects it to be iterable or defined, e.g. Jest:
2707
2697
  // https://github.com/jestjs/jest/blob/b4c9587/packages/pretty-format/src/plugins/DOMElement.ts#L95
2708
2698
  // It also doesn't make sense to override e.g. "constructor".
2709
- .filter((propName) => !(propName in HTMLElementPrototype) &&
2710
- !(propName in ariaReflectionPolyfillDescriptors)));
2699
+ .filter((propName) => !(propName in HTMLElementPrototype)));
2711
2700
  for (const propName of nonPublicPropertiesToWarnOn) {
2712
2701
  if (ArrayIndexOf.call(publicProperties, propName) === -1) {
2713
2702
  descriptors[propName] = createAccessorThatWarns(propName);
@@ -2777,22 +2766,21 @@ function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observe
2777
2766
  defineProperties(HTMLBridgeElement.prototype, descriptors);
2778
2767
  return HTMLBridgeElement;
2779
2768
  }
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);
2769
+ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), [], [], null, false);
2770
+ if (process.env.IS_BROWSER) {
2771
+ // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
2772
+ // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
2773
+ // ARIA props outside the LightningElement
2774
+ //
2775
+ // Apply ARIA reflection to HTMLBridgeElement.prototype. This allows `elm.aria*` property accessors to work from
2776
+ // outside a component, and to reflect `aria-*` attrs. This is especially important because the template compiler
2777
+ // compiles aria-* attrs on components to aria* props.
2778
+ // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
2779
+ //
2780
+ // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
2781
+ // accessors inside the HTMLBridgeElementFactory.
2782
+ applyAriaReflection(BaseBridgeElement.prototype);
2783
+ }
2796
2784
  freeze(BaseBridgeElement);
2797
2785
  seal(BaseBridgeElement.prototype);
2798
2786
 
@@ -7325,5 +7313,5 @@ function readonly(obj) {
7325
7313
  }
7326
7314
 
7327
7315
  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 };
7328
- /** version: 5.0.4 */
7316
+ /** version: 5.0.6 */
7329
7317
  //# sourceMappingURL=index.js.map