/* non-shadow dom minimal custom element */
customElements.define("counter-ce", class extends HTMLElement {
connectedCallback() {
this.innerHTML = `
`;
this.update = ()=>{
this.querySelector('span').innerHTML = eval(this.getAttribute('value'))
}
this.update();
eval(this.getAttribute('onload'));
}
// -- optional, if you need to listen on attribute changes
static get observedAttributes() { return ['value'] };
attributeChangedCallback (attr, oldValue, newValue) {
// first time, it triggers before element is initialized
if (this.update) this.update();
}
});
/* example using a global redux-like store
My button text
*/