@lwc/synthetic-shadow 6.1.1 → 6.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/index.cjs.js CHANGED
@@ -64,6 +64,8 @@ function isTrue(obj) {
64
64
  function isFalse(obj) {
65
65
  return obj === false;
66
66
  }
67
+ // Replacing `Function` with a narrower type that works for all our use cases is tricky...
68
+ // eslint-disable-next-line @typescript-eslint/ban-types
67
69
  function isFunction(obj) {
68
70
  return typeof obj === 'function';
69
71
  }
@@ -107,7 +109,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
107
109
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
108
110
  const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
109
111
  const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
110
- /** version: 6.1.1 */
112
+ /** version: 6.2.0 */
111
113
 
112
114
  /**
113
115
  * Copyright (c) 2024 Salesforce, Inc.
@@ -115,7 +117,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
115
117
  if (!globalThis.lwcRuntimeFlags) {
116
118
  Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
117
119
  }
118
- /** version: 6.1.1 */
120
+ /** version: 6.2.0 */
119
121
 
120
122
  /*
121
123
  * Copyright (c) 2018, salesforce.com, inc.
@@ -914,12 +916,11 @@ function createStaticNodeList(items) {
914
916
  */
915
917
  // Walk up the DOM tree, collecting all shadow roots plus the document root
916
918
  function getAllRootNodes(node) {
917
- var _a;
918
919
  const rootNodes = [];
919
920
  let currentRootNode = node.getRootNode();
920
921
  while (!isUndefined(currentRootNode)) {
921
922
  rootNodes.push(currentRootNode);
922
- currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
923
+ currentRootNode = currentRootNode.host?.getRootNode();
923
924
  }
924
925
  return rootNodes;
925
926
  }
@@ -1187,6 +1188,7 @@ const nativeGetRootNode = _Node.prototype.getRootNode;
1187
1188
  const getDocumentOrRootNode = !isUndefined(nativeGetRootNode)
1188
1189
  ? nativeGetRootNode
1189
1190
  : function () {
1191
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1190
1192
  let node = this;
1191
1193
  let nodeParent;
1192
1194
  while (!isNull((nodeParent = parentNodeGetter.call(node)))) {
@@ -1466,7 +1468,7 @@ function getEventHandler(listener) {
1466
1468
  }
1467
1469
  }
1468
1470
  function isEventListenerOrEventListenerObject(listener) {
1469
- return isFunction(listener) || isFunction(listener === null || listener === void 0 ? void 0 : listener.handleEvent);
1471
+ return isFunction(listener) || isFunction(listener?.handleEvent);
1470
1472
  }
1471
1473
  const customElementToWrappedListeners = new WeakMap();
1472
1474
  function getEventMap(elm) {
@@ -1483,8 +1485,7 @@ function getEventMap(elm) {
1483
1485
  * abstraction and properly returns a reference to the shadow root when appropriate.
1484
1486
  */
1485
1487
  function getActualTarget(event) {
1486
- var _a;
1487
- return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
1488
+ return eventToShadowRootMap.get(event) ?? eventTargetGetter.call(event);
1488
1489
  }
1489
1490
  const shadowRootEventListenerMap = new WeakMap();
1490
1491
  function getManagedShadowRootListener(listener) {
@@ -1621,7 +1622,7 @@ function detachDOMListener(elm, type, managedListener) {
1621
1622
  function addCustomElementEventListener(type, listener, _options) {
1622
1623
  if (process.env.NODE_ENV !== 'production') {
1623
1624
  if (!isEventListenerOrEventListenerObject(listener)) {
1624
- throw new TypeError(`Invalid second argument for Element.addEventListener() in ${toString(this)} for event "${type}". Expected EventListener or EventListenerObject but received ${listener}.`);
1625
+ throw new TypeError(`Invalid second argument for Element.addEventListener() in ${toString(this)} for event "${type}". Expected EventListener or EventListenerObject but received ${toString(listener)}.`);
1625
1626
  }
1626
1627
  }
1627
1628
  if (isEventListenerOrEventListenerObject(listener)) {
@@ -1638,7 +1639,7 @@ function removeCustomElementEventListener(type, listener, _options) {
1638
1639
  function addShadowRootEventListener(sr, type, listener, _options) {
1639
1640
  if (process.env.NODE_ENV !== 'production') {
1640
1641
  if (!isEventListenerOrEventListenerObject(listener)) {
1641
- throw new TypeError(`Invalid second argument for ShadowRoot.addEventListener() in ${toString(sr)} for event "${type}". Expected EventListener or EventListenerObject but received ${listener}.`);
1642
+ throw new TypeError(`Invalid second argument for ShadowRoot.addEventListener() in ${toString(sr)} for event "${type}". Expected EventListener or EventListenerObject but received ${toString(listener)}.`);
1642
1643
  }
1643
1644
  }
1644
1645
  if (isEventListenerOrEventListenerObject(listener)) {
@@ -4251,6 +4252,6 @@ defineProperty(Element.prototype, '$domManual$', {
4251
4252
  },
4252
4253
  configurable: true,
4253
4254
  });
4254
- /** version: 6.1.1 */
4255
+ /** version: 6.2.0 */
4255
4256
  }
4256
4257
  //# sourceMappingURL=index.cjs.js.map