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
useEventListener can be confused to not clean up events. #2825
Comments
Actually, ignore my "simple" fix, I just realised it doesn't work with when options is empty or a string.. but it should be similar, but with type checking |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not Stale |
Has any maintainer even seen this issue yet? Care to comment? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Thank you @antfu |
Describe the bug
I will start off, that someone would have to go out of their way to cause this bug, but I just thought best to show it exists..
capture: true
binds to a different set of internal in the element.el.addEventListener("click", handle, { capture: true })
and thenel.removeEventListener("click", handle, { capture: false})
to remove the event listener.true
object while the handler is attached to 1 targetThis is ALSO true if you change the options object, and then remove the element off the screen.
shared.tryOnScopeDispose(stop)
could fail to remove the listener.. but You would have to start self referencing in the callback to attempt to stop that type of GC cleanup.I believe a simple fix of
Reproduction
https://sfc.vuejs.org/#eNrFVcFu2zAM/RXOGJAES220xyxJW7S9FeuwdYcBPtSxmVitLQmSHLcw/O+jLNuN0ybrYcAuiSU+PpJPFFV5l1L62wK9mTfXsWLSgEZTyGXIWS6FMlCBwvUUYpHLwmAypWUUG7bFKRScTFDDWokcRsQy2vEqNN5skZtbpg1yVD3ugoBkDGKhcPQ15LHg2oCJ1AbNKSxsuPFkb//swP7Pkpk4bY1GFbgPIFOX+Xg8gcXSJT12v7skEzjvk5h1YSeTId39IT5nnpz7jFOt9/hsXjMR0jD6aLJ00o0rCIJ+n2nIowRJMcY3PQa+//pxc/sb1kJBwrTMohdrZhxMimAwpx1DhxCBJs0zBLF6xNhAKYosAV2s10xj421SirAqNn7IAeJImkIhVUhqTUNe2zz3z6otZwqhF2csfgq9KYxxa5qCK0sjCkMi+NsoKxC+LODhc3VN6fhclONJDVfWCz5X5OM7rldh6jDkDxS0nnYK9CI71vY4RyPaD/m64KSH4CB4w3rnfEh8l4hb+m1d5Ptpb8uGektz32TVsew2QlsUEb3ddVzzwF0VuiS06I6CVgBzkTX/9JWxpZMh9FwwOA09OgdjBDGQ9SDu7BDubqVRUWsInr3YnC0nxNQxBnUr3gHmqzTiGwQX4INp/Nt0B/BhzhDxpOnqptmAUk0yGhhpRG2LyKkbcrHFxM2P3fSOF9t2yt+q+K/SrIRJh7SX366Pa6Xfkaqk3YJHKxoDRhzQy3K1znSt3d2gLamERGVeGg4uaNIRQEc5WnCZkvyMhgp9R1JmDBO/r2QetM0+dyXaW7sIvXaIht6yq2oeOMBBMKXWgc+G4FQNnC6asslvcIvJe3CIM6iqdl7X9bvB93n6VumI2g3L1I6TfaYuM6lwSaDmcCzGru2I6MeCN/Xco3iSR9J/1ILTY9tMnbA1UFwK5Joj9Oh5tOvQS42RehYEeh3bJ/pR+0JtAvryVcENy9FHnZ+slCipl4iYpvQOx0mCORsSlWXpF1w+bXx6wyxRg6HjXAWMJ/js5wOS7qHWKU2a5BjVEHmUzL76H6GyuHeJyB40d0edKCS7QnVMrj3oG8ksLY302qv/ADe/H8Y=
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: