@lwc/synthetic-shadow 2.7.1 → 2.7.2

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.
@@ -194,7 +194,7 @@ const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
194
194
 
195
195
 
196
196
  const hasNativeSymbolSupport = /*@__PURE__*/(() => Symbol('x').toString() === 'Symbol(x)')();
197
- /** version: 2.7.1 */
197
+ /** version: 2.7.2 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1524,7 +1524,7 @@ if (!_globalThis.lwcRuntimeFlags) {
1524
1524
  }
1525
1525
 
1526
1526
  const runtimeFlags = _globalThis.lwcRuntimeFlags;
1527
- /** version: 2.7.1 */
1527
+ /** version: 2.7.2 */
1528
1528
 
1529
1529
  /*
1530
1530
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2010,7 +2010,22 @@ function getAllRootNodes(node) {
2010
2010
  }
2011
2011
 
2012
2012
  return rootNodes;
2013
- }
2013
+ } // Keep searching up the host tree until we find an element that is within the immediate shadow root
2014
+
2015
+
2016
+ const findAncestorHostInImmediateShadowRoot = (rootNode, targetRootNode) => {
2017
+ let host;
2018
+
2019
+ while (!isUndefined(host = rootNode.host)) {
2020
+ const thisRootNode = host.getRootNode();
2021
+
2022
+ if (thisRootNode === targetRootNode) {
2023
+ return host;
2024
+ }
2025
+
2026
+ rootNode = thisRootNode;
2027
+ }
2028
+ };
2014
2029
 
2015
2030
  function fauxElementsFromPoint(context, doc, left, top) {
2016
2031
  const elements = elementsFromPoint.call(doc, left, top);
@@ -2024,8 +2039,28 @@ function fauxElementsFromPoint(context, doc, left, top) {
2024
2039
  for (let i = 0; i < elements.length; i++) {
2025
2040
  const element = elements[i];
2026
2041
 
2027
- if (rootNodes.indexOf(element.getRootNode()) !== -1 && !isSyntheticSlotElement(element)) {
2028
- result.push(element);
2042
+ if (isSyntheticSlotElement(element)) {
2043
+ continue;
2044
+ }
2045
+
2046
+ const elementRootNode = element.getRootNode();
2047
+
2048
+ if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
2049
+ ArrayPush.call(result, element);
2050
+ continue;
2051
+ } // In cases where the host element is not visible but its shadow descendants are, then
2052
+ // we may get the shadow descendant instead of the host element here. (The
2053
+ // browser doesn't know the difference in synthetic shadow DOM.)
2054
+ // In native shadow DOM, however, elementsFromPoint would return the host but not
2055
+ // the child. So we need to detect if this shadow element's host is accessible from
2056
+ // the context's shadow root. Note we also need to be careful not to add the host
2057
+ // multiple times.
2058
+
2059
+
2060
+ const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
2061
+
2062
+ if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
2063
+ ArrayPush.call(result, ancestorHost);
2029
2064
  }
2030
2065
  }
2031
2066
  }
@@ -5680,4 +5715,4 @@ defineProperty(Element.prototype, '$domManual$', {
5680
5715
 
5681
5716
  configurable: true
5682
5717
  });
5683
- /** version: 2.7.1 */
5718
+ /** version: 2.7.2 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/synthetic-shadow",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "Synthetic Shadow Root for LWC",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "access": "public"
37
37
  },
38
38
  "devDependencies": {
39
- "@lwc/features": "2.7.1",
40
- "@lwc/shared": "2.7.1"
39
+ "@lwc/features": "2.7.2",
40
+ "@lwc/shared": "2.7.2"
41
41
  },
42
- "gitHead": "1b2e246e03c6bfbc80bea3def43b7d0281a1de21"
42
+ "gitHead": "f668a3ad36bbebbaa33a5863408a45bf4185d218"
43
43
  }