<my-ce name="Initial Name"></my-ce>
<script>
class MyCe extends HTMLElement {
constructor() {
super()
this.textContent = 'Hello, World!'
}
static get observedAttributes() {
return ['name']
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === 'name') {
this.textContent = newValue
}
}
}
customElements.define('my-ce', MyCe)
</script>