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