0

I'm learning about custom elements / web components, and was not sure why my connectedCallback() and attributeChangedCallback() methods never seemed to get called and did not receive any errors, but finally found out I had created each of them as arrow functions. Changing them to a regular function got things working again.

Why would connectedCallback and attributeChangedCallback() not work as arrow functions? Does being an arrow function change the scope in a way that they can't be used in a custom element? How does this relate to the use of "this" within the web component, and would it be a problem if other methods in the web component are arrow functions? (< this seems to work fine, but will my this from the arrow functions be somehow a higher level than the this from the non-arrow connectedCallback etc?)

David Mays
  • 466
  • 4
  • 14

0 Answers0