hathitrust / firebird-common

Other
0 stars 0 forks source link

fix matomo function #82

Closed carylwyatt closed 6 months ago

carylwyatt commented 6 months ago

After staging the latest a11y fixes on dev-3, I noticed the console giving this error:

 Uncaught TypeError: Cannot read properties of undefined (reading 'service')
    at addMatomoScript (index-078c1e23.js:14:3660)

After some googling, I learned that in order to have the context of this in a method in javascript, you need to use the arrow function syntax. I tested this on dev-3 and it fixed the issue, and the tests are still passing.

netlify[bot] commented 6 months ago

Deploy Preview for hathitrust-firebird-common ready!

Name Link
Latest commit f9879c311128675a2d9a66c72af80fe07dfc4e05
Latest deploy log https://app.netlify.com/sites/hathitrust-firebird-common/deploys/66439b1eb914de000868ce2d
Deploy Preview https://deploy-preview-82--hathitrust-firebird-common.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

carylwyatt commented 6 months ago

I don't have a sense of which to prefer. The behavior from the outside is the same in any of the cases.

Yes, there are a few ways to bind 'this' to the global object, but like you say, it's probably up to preference as to which way to do it. Do we want to leave the addMatomoScript()method as it was and amend the callback function for configure()? Either way is fine by me, I'm still learning how to do things in an OOP way.