UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

27 lines (26 loc) 1.04 kB
import { parseQueryStringKeyValues as lt } from "../../util/url-utils.js"; import { WindowUtils as no } from "../../util/window-utils.js"; import { IamOpenTarget as ut } from "../constants.js"; import { logInAppMessageHtmlClick } from "../log-in-app-message-html-click.js"; export const buildHtmlClickHandler = (t, l, i, o) => { const r = i.getAttribute("href"), n = i.onclick; return (s) => { if (null != n && "function" == typeof n && !1 === n.bind(i)(s)) return; let e = lt(r).abButtonId; if ( ((null != e && "" !== e) || (e = i.getAttribute("id") || void 0), null != r && "" !== r && 0 !== r.indexOf("#")) ) { const n = "blank" === (i.getAttribute("target") || "").toLowerCase().replace("_", ""), u = o || t.openTarget === ut.BLANK || n, m = () => { logInAppMessageHtmlClick(t, e, r), no.openUri(r, u, s); }; u ? m() : t.tl(l, m); } else logInAppMessageHtmlClick(t, e, r || void 0); return s.stopPropagation(), !1; }; };