use capture phase

pull/10617/head
Simon Holthausen 2 years ago
parent b8b5655bdf
commit 4ff8995053

@ -54,15 +54,20 @@ export function listen_to_event_and_reset_event(element, event, handler, on_rese
if (!listening_to_form_reset) { if (!listening_to_form_reset) {
listening_to_form_reset = true; listening_to_form_reset = true;
document.addEventListener('reset', (evt) => { document.addEventListener(
requestAnimationFrame(() => { 'reset',
if (!evt.defaultPrevented) { (evt) => {
for (const e of /**@type {HTMLFormElement} */ (evt.target).elements) { requestAnimationFrame(() => {
// @ts-expect-error if (!evt.defaultPrevented) {
e.__on_r?.(); for (const e of /**@type {HTMLFormElement} */ (evt.target).elements) {
// @ts-expect-error
e.__on_r?.();
}
} }
} });
}); },
}); // In the capture phase to guarantee we get noticed of it (no possiblity of stopPropagation)
{ capture: true }
);
} }
} }

Loading…
Cancel
Save