fix: Various editor / diagnostic improvements (#2363)

- Closes: #2360 
 - Closes: #2328
This commit is contained in:
Dermot Duffy
2026-02-21 09:31:10 -08:00
committed by GitHub
parent 6d5a76ac0a
commit df3614f793
13 changed files with 313 additions and 58 deletions
+21
View File
@@ -0,0 +1,21 @@
/**
* Walk up `element`'s ancestor chain (through shadow boundaries) looking for
* an ancestor with the given tag name. Returns true if one is found and that
* same element also appears in the event's composedPath — indicating the event
* originated from within the same subtree as the element.
*/
export const isAncestorInEventPath = (
element: Element,
ev: Event,
tagName: string,
): boolean => {
const composedPath = ev.composedPath();
let node: Node | null = element;
while (node) {
if (node instanceof Element && node.tagName.toLowerCase() === tagName) {
return composedPath.includes(node);
}
node = node instanceof ShadowRoot ? node.host : node.parentNode;
}
return false;
};