Ensure duplicate snap events are not registered on the same feature#17054
Merged
ahocevar merged 1 commit intoAug 27, 2025
Merged
Conversation
|
📦 Preview the website for this branch here: https://deploy-preview-17054--ol-site.netlify.app/. |
140a53c to
1e1c628
Compare
ahocevar
approved these changes
Aug 27, 2025
ahocevar
approved these changes
Aug 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Description
If a
Snapis watching a collection and a feature is added to the collection which already exists in it, theSnapwill register event listeners to the feature twice. Later, if the Snap is removed, viamap.removeInteraction(snap), a rogue event listener will still exist which can cause JS errors. The error in my case would cause the entire map stack to crash inaddFeatureasthis.getMap()will be null.This was a bug in my application but was quite difficult to track down and can lead to memory leaks.
Workaround
This ensures any events registered to a feature are cleaned up if snap attempts to bind to the feature again.