app-walkthrough
Version:
An intuitive guided walkthrough library with UI highlighting and voice narration for web apps.
17 lines (16 loc) • 447 B
JavaScript
export function safeClick(element) {
if (!element)
return;
// If element has a native .click method, use it.
if (typeof element.click === "function") {
element.click();
return;
}
// If not, dispatch a real mouse event that bubbles up correctly
const event = new MouseEvent("click", {
bubbles: true,
cancelable: true,
view: window,
});
element.dispatchEvent(event);
}