-
Notifications
You must be signed in to change notification settings - Fork 162
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
chore: Replace removeEventListener with abort controller #3206
Conversation
@@ -93,7 +93,7 @@ export function animate({ | |||
if (event.target === element) { | |||
// Clean up remaining inline styles | |||
element.style.transitionProperty = ''; | |||
element.removeEventListener('transitionstart', onTransitionEnd); | |||
element.removeEventListener('transitionend', onTransitionEnd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not have to do anything with AbortController
, I just noticed this typo
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3206 +/- ##
========================================
Coverage 96.42% 96.42%
========================================
Files 787 787
Lines 22195 22191 -4
Branches 7209 7614 +405
========================================
- Hits 21401 21398 -3
+ Misses 787 786 -1
Partials 7 7 ☔ View full report in Codecov by Sentry. |
…ts listeners are attached to specific instances
jest.spyOn(tableRef.current!, 'removeEventListener').mockImplementation(rootRemoveEventListener as any); | ||
abortFn(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see AbortController being used in table/use-table-focus-navigation.ts
so the test shouldn't be changed. And it's very normal that the related test is passing because basically here you are directly calling the function and asserting that it is called below in the test. So even abort was used in the file, I don't think these two lines are really testing the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I initially introduced AbortController
in the table/use-table-focus-navigation.ts
, but then decided to get rid of it, because it didn't bring any benefit there. Addressed
Description
Replaced
removeEventListener
withAbortController.abort
where it brought code clarify, specifically when multiple event listeners should be removed at once.Dry-run: 7201850483
The
AbortController
is supported injest
from version 27. For those who use older versions (if any), should either update theirjest
or use a workaround, for instance, this one: facebook/create-react-app#11626 (comment)Related links, issue #, if available: n/a
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
.CONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.