[Utility - Userscript] WK Custom Icons Library

It seems that the problem with turbo:load has resurfaced. Looking at your code, the problem is that setUpSVGElements() is now using this, but you provide addEventListener() only with the function without information about the context in which the function should run.

Two possible solutions would be:

  1. Bind the desired context to the function:
    document.addEventListener("turbo:load", Icons.setUpSVGElements.bind(Icons));
    
  2. Give addEventListener a function that in turn calls Icons.setUpSVGElements(), in which case JavaScript uses the class on which the method was called for this:
    document.addEventListener("turbo:load", () => Icons.setUpSVGElements());
    

Also, I noticed that the top post still says that 1350892 is the latest version number.

1 Like