<form> <button onclick="form.counter.value -= 1;return false">-</button> <input name="counter" value="0"> <button onclick="form.counter.value = 1 + +form.counter.value;return false">+</button> </form>
class MyCounter extends HTMLElement { connectedCallback() { this.attachShadow({mode: 'open'}).innerHTML = `<style>...</style><form>...</form>` } } customElements.define('my-counter', MyCounter)