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: auto init memory leak #441

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oliverhaas
Copy link

@oliverhaas oliverhaas commented Aug 13, 2024

This PR fixes a memory leak in autoInit() of combobox, select, dropdown, overlay, tabs.

When using autoInit() repeatedly, e.g. when doing partial updates with ajax like in the docs https://preline.co/docs/preline-javascript.html, some components will repeatedly initialize global event listeners, even though the repeated ones are not needed.

This PR fixes that just by only registering the event listeners the first time an autoInit() is called.

@oliverhaas
Copy link
Author

oliverhaas commented Aug 13, 2024

@langscot Pinging you since you commented on my earlier (messy) PR.

This PR does not address an issue with cleaning up old/destroyed components. My PR only reduces the amount of unnecessarily registered duplicate event listeners in autoInit().

I don't really understand what's the issue with the clean up of old components in autoInit like you're suggesting in #438.

@langscot
Copy link

Looked over the commits and looks really solid, nice work 👍

I seen "auto init memory leak" and my mind instantly jumped to the other cleanup issue I had going on, sorry about that.

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.

2 participants