I’m working with custom elements which execute a callback after something happens.
When adding this element in HTML,
<custom-element callback="change(this)"></custom-element>
how can we convert the callback attribute value to the function and execute it, like the common onclick attribute (without eval)?
<div onclick="change(this)"></div>
class CustomElement extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
let func = this.getAttribute('callback'); //and then?
}
}