1 comment

[ 0.25 ms ] story [ 13.6 ms ] thread
I think the author is looking for the `.bind` method of the .click function [1], which explicitly specifies which object to use as `this`. Using that their code would be

  document.getElementById("eta-reduced").onclick = listener.click.bind(listener);
Which is a little clunky, but shorten than before. Alternatively, an arrow function would also get the job done:

  document.getElementById("eta-reduced").onclick = e => listener.click();
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...