Created
January 5, 2017 13:11
-
-
Save bendc/ef1b7055b135f7a4f3f8cead348a4576 to your computer and use it in GitHub Desktop.
Web Components: hello-message-attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
customElements.define("hello-message", class extends HTMLElement { | |
constructor() { | |
super(); | |
const root = this.attachShadow({mode: "open"}); | |
root.innerHTML = "Hello <slot></slot>"; | |
} | |
static get observedAttributes() { | |
return ["name"]; | |
} | |
attributeChangedCallback(name, old, change) { | |
this.textContent = change; | |
} | |
}); | |
document.body.innerHTML = "<hello-message name=Jane></hello-message>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment