Skip to content
New issue

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

fix: prevent setting the same event listener twice #2383

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

Giovanni-Tably
Copy link
Contributor

Delegated event listeners do not support adding more than one event listener of the same type. This can cause confusion if two listeners are added, as one is silently dropped.

Here I just assert that the value does not exist yet, which was what we decided to go with internally (it seems good practice to avoid double listeners, if possible).

Alternatives:

  • Switch to a warning.
  • Combine the two event listeners.

leptos_dom/src/events.rs Outdated Show resolved Hide resolved
Delegated event listeners do not support adding more than one event listener of the same type. This can cause confusion if two listeners are added, as one is silently dropped.
@gbj gbj merged commit 2b4f5e0 into leptos-rs:main Mar 7, 2024
@Giovanni-Tably Giovanni-Tably deleted the listener-overwrite branch March 8, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants