Use AbortController for input event cleanup #247
+433
−12
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.
Hello. Thanks for cool library.
I find out sometimes cleanup is not fully happen and dead events still exists on page after mask was destroyed. Possible reason of this issue, if on page exists DOM mutation lib, like https://github.com/bigskysoftware/idiomorph , which may use
replaceChild
to update elements (which may lead reference in map will not have old event).I decided will be faster and not loose any listener to use https://developer.mozilla.org/en-US/docs/Web/API/AbortController and just call it instead iterate over all created
addEventListener
(alpinejs example doing same - https://github.com/alpinejs/alpine/blob/main/packages/mask/src/index.js#L46 ).Problem, that
happy-dom
not implementedAbortController
foraddEventListener
, but it hasjsdom
.So I moved test, which check this functionality in separate file, where activatejsdom
insteadhappy-dom
(I tried activatejsdom
for whole test suite, but one alpinejs tests is failing)up: decided better figure out why alpine not workingup up: alpinejs test fixed