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

trigger the "onunload" event only if the node is not mounted on the DOM #25

Open
yoshuawuyts opened this issue Jun 14, 2017 · 1 comment

Comments

@yoshuawuyts
Copy link
Collaborator

Problem

on-load works by hooking into a MutationObserver and listening for change events. These events are the very first thing that resolve on each frame.

Sometimes DOM nodes are briefly removed from the DOM, only to be immediately reinserted. Reordering / sorting lists is a common example of this. Because of how on-load is currently set up, even briefly removing an element from the DOM can cause the MutationObserver to trigger.

This makes it impossible to reorder lists of elements with onload() listeners attached.

Proposal

I propose we mitigate this by having on-load check if the node is still on the DOM by the time the MutationObserver resolves, so list reordering can be performed. My gut feeling tells me this shouldn't cause any significant performance overhead. Thanks!

See Also

@bcomnes
Copy link
Collaborator

bcomnes commented Aug 10, 2018

This should be fixed in 4.0.0 lets reopen if its not.

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

No branches or pull requests

2 participants