ITADN

Use AbortController for input event cleanup

#247Pull Requestle0pard 创建于 2024-11-17
L
le0pardcommented
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). <img width="843" alt="Screenshot 2024-11-17 at 03 01 01" src="https://github.com/user-attachments/assets/3d381fa2-e0fe-4556-b2dd-185ae48efc3d"> 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 implemented `AbortController` for `addEventListener`](https://github.com/capricorn86/happy-dom/issues/1540), but it has `jsdom`. ~~So I moved test, which check this functionality in separate file, where activate `jsdom` instead `happy-dom` (I tried activate `jsdom` for whole test suite, but one alpinejs tests is failing)~~ ~~up: decided better figure out why alpine not working~~ up up: alpinejs test fixed
合并状态:未合并 关闭于 2024-11-28 4 条评论