We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
svelte/no-add-event-listner
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We need to use on instead. https://svelte.dev/docs/svelte/svelte-events#on
on
Since Svelte 5 uses event delegation, using addEventListener may cause events to fire in unexpected order. Therefore, we should always use on instead.
addEventListener
<script> import { on } from 'svelte/events'; onMount(() => { // ✓ GOOD on(parent, 'click',() => {}); // ✗ BAD parent.addEventListener('click',() => {}); }) </script> <div bind:this={parent}> <button /> </div>
No response
The text was updated successfully, but these errors were encountered:
no-add-event-listener
Successfully merging a pull request may close this issue.
Motivation
We need to use
on
instead.https://svelte.dev/docs/svelte/svelte-events#on
Description
Since Svelte 5 uses event delegation, using
addEventListener
may cause events to fire in unexpected order.Therefore, we should always use
on
instead.Examples
Additional comments
No response
The text was updated successfully, but these errors were encountered: