Skip to content

Commit 4ff8995

Browse files
committed
use capture phase
1 parent b8b5655 commit 4ff8995

File tree

1 file changed

+14
-9
lines changed
  • packages/svelte/src/internal/client/dom/elements/bindings

1 file changed

+14
-9
lines changed

packages/svelte/src/internal/client/dom/elements/bindings/shared.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,20 @@ export function listen_to_event_and_reset_event(element, event, handler, on_rese
5454

5555
if (!listening_to_form_reset) {
5656
listening_to_form_reset = true;
57-
document.addEventListener('reset', (evt) => {
58-
requestAnimationFrame(() => {
59-
if (!evt.defaultPrevented) {
60-
for (const e of /**@type {HTMLFormElement} */ (evt.target).elements) {
61-
// @ts-expect-error
62-
e.__on_r?.();
57+
document.addEventListener(
58+
'reset',
59+
(evt) => {
60+
requestAnimationFrame(() => {
61+
if (!evt.defaultPrevented) {
62+
for (const e of /**@type {HTMLFormElement} */ (evt.target).elements) {
63+
// @ts-expect-error
64+
e.__on_r?.();
65+
}
6366
}
64-
}
65-
});
66-
});
67+
});
68+
},
69+
// In the capture phase to guarantee we get noticed of it (no possiblity of stopPropagation)
70+
{ capture: true }
71+
);
6772
}
6873
}

0 commit comments

Comments
 (0)