@mocanvas/editor · function

loopToHtmlElement

declare function loopToHtmlElement(node: Node | EventTarget | null | undefined): HTMLElement | null

Walk up from node to the first HTMLElement, or null.

Event targets are not always elements: a click inside a text shape lands on a Text node, and a click on an SVG lands on an SVGElement whose parentElement chain leads back to HTML. Anything that wants to ask "which shape was this?" has to normalise first.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.