Created
February 21, 2018 14:45
-
-
Save sz332/56625a3e4036eec01eb0ad2d84c488fe to your computer and use it in GitHub Desktop.
Custom element
This file contains 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
<html> | |
<head> | |
<script> | |
class HelloWorld extends HTMLElement { | |
constructor() { | |
super(); | |
let shadowRoot = this.attachShadow({ | |
mode: 'open' | |
}); | |
let label = document.createElement("span"); | |
label.textContent = "Hello world"; | |
shadowRoot.appendChild(label); | |
} | |
} | |
customElements.define("hello-world", HelloWorld); | |
</script> | |
</head> | |
<body> | |
<hello-world></hello-world> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment