UNPKG

@clopezochoa/detect-autofill-react

Version:

React hook to detect browser's autofill

24 lines (23 loc) 606 B
function u(n, e) { return new Promise((t) => { if (e != null && e.aborted) { t(!1); return; } const a = 25, o = 1e3; let c = 0; const r = window.setInterval(() => { if (e != null && e.aborted) { clearInterval(r), t(!1); return; } window.getComputedStyle(n, null).getPropertyValue("appearance") === "menulist-button" ? (clearInterval(r), t(!0)) : (c += a, c >= o && (clearInterval(r), t(!1))); }, a); e == null || e.addEventListener("abort", () => { clearInterval(r), t(!1); }); }); } export { u as detectAutofill };