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: remove link handler in disconnect #6901

Merged
merged 4 commits into from
May 30, 2024
Merged

Conversation

xuwaters
Copy link
Contributor

@xuwaters xuwaters commented Jan 28, 2024

Pull Request

πŸ“– Description

Click event handler should be removed properly in disconnect method of DefaultLinkHandler.
Since the event listener is added with useCapture = true in connect method, it's required to set useCapture = true in removeEventListener according to https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#matching_event_listeners_for_removal

🎫 Issues

When the :config property of fast-router is updated, the tryConnect method will disconnect link handler and connect again. In this case, the previous click event handler is not properly removed, which results in resource leak.

πŸ‘©β€πŸ’» Reviewer Notes

πŸ“‘ Test Plan

βœ… Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

⏭ Next Steps

@xuwaters xuwaters marked this pull request as ready for review January 28, 2024 10:59
@scomea
Copy link
Collaborator

scomea commented Jan 31, 2024

This looks like the right thing to do, but regardless there should be some explanatory description in the PR.

@xuwaters
Copy link
Contributor Author

xuwaters commented Feb 1, 2024

This looks like the right thing to do, but regardless there should be some explanatory description in the PR.

Description updated.

@janechu janechu merged commit a789e14 into microsoft:master May 30, 2024
5 checks passed
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

4 participants