attach listeners to data-modal when they become visible#206
Merged
plegner merged 3 commits intomathigon:masterfrom Oct 23, 2025
Merged
Conversation
swarty
reviewed
Oct 22, 2025
| * Attaches a click listener to an element with data-modal attribute, if there isn't one already. | ||
| */ | ||
| attachListener($button: any) { | ||
| if (elementsWithModalListeners.has($button._el)) return; |
Contributor
There was a problem hiding this comment.
i think in case with :if we need to remove listeners from element and browser and do not keep them because of sense of this listener, that is why i think this line creates space for memory leak when elements will be cut from DOM but we keep listeners for them in memory.
Contributor
Author
There was a problem hiding this comment.
That's a good point. I just pushed changes which remove the listeners when the element is detached from the dom.
swarty
approved these changes
Oct 23, 2025
| removeListener($button: ElementView) { | ||
| if (!elementsWithModalListeners.has($button._el)) return; | ||
|
|
||
| $button.off('click'); |
Contributor
There was a problem hiding this comment.
ok, now it should remove all click events, not just modal component, i think it is fine
Contributor
|
@zachicecreamcohn you also need ask review Philip because he only has permissions to merge PRs into boost |
plegner
approved these changes
Oct 23, 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.
Currently, listeners are only attached to elements with the
data-modalattribute if they're are visible on load or when navigating.This means that if you have an element with
data-modalthat is initially hidden with:if, listeners will not be attached to that element when it becomes visible.This PR fixes that