Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ts/drag-drop-touch-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function newForwardableEvent(
const evt = new Event(type, {
bubbles: true,
cancelable: true,
composed: target.shadowRoot?.mode === "open",
}) as unknown as Mutable<MouseEvent, "button" | "which" | "buttons"> & {
readonly defaultPrevented: boolean;
},
Expand All @@ -68,6 +69,19 @@ export function newForwardableEvent(
copyProps(evt, srcEvent, _kbdProps);
copyProps(evt, touch, _ptProps);
setOffsetAndLayerProps(evt, target);
// set composedPath for shadow DOM
if (evt.composed) {
evt.composedPath = () => {
const pt = pointFrom(srcEvent);
const el = target.shadowRoot?.elementFromPoint(pt.x, pt.y);
const getPath = (e?: Element | null, path: Element[] = []) => {
if (!e) return path;
path.unshift(e);
return getPath(e.parentElement, path);
};
return getPath(el);
};
}
return evt;
}

Expand Down