Skip to content

Instantly share code, notes, and snippets.

@sz332
Created February 21, 2018 14:45
Show Gist options
  • Save sz332/56625a3e4036eec01eb0ad2d84c488fe to your computer and use it in GitHub Desktop.
Save sz332/56625a3e4036eec01eb0ad2d84c488fe to your computer and use it in GitHub Desktop.
Custom element
<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