kamranahmedse / driver.js

A light-weight, no-dependency, vanilla JavaScript engine to drive the user's focus across the page

Home Page:https://driverjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential memory leaks with event listeners

k-ivan opened this issue · comments

commented

Thanks for the great plugin!

It seems to me that in the method for removing event handlers there is not enough removal for the keydown event.
https://github.com/kamranahmedse/driver.js/blob/master/src/events.ts#L118

commented

And it’s not enough to delete events in this place, especially important for SPA project.

document.addEventListener("pointerdown", listenerWrapper, useCapture);
-

All these events, each time the method drive() launched, multiply the number of handlers.

commented

Maybe I'm missing something, but on the screen there are 3 states after calling the method (check with getEventListeners(document))

  1. before the plugin works
  2. first launch driver
  3. re-launch driver(or prev|next click)

image

commented

Hello @kamranahmedse !
I wanted to ask if you are still maintaining this wonderful plugin, could you consider my PR on this issue?

I would really like to solve this problem.