Skip to content

Instantly share code, notes, and snippets.

@sindrenm
Created November 9, 2016 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sindrenm/75e998f4c98562b3ed34cf257db70d6e to your computer and use it in GitHub Desktop.
Save sindrenm/75e998f4c98562b3ed34cf257db70d6e to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Web Components Test</title>
<script>
class ClickCounter extends HTMLElement {
constructor() {
super();
this._clickCount = 0;
this.addEventListener('click', () => {
this.innerHTML = `Clicked ${++this._clickCount} times!`;
});
}
connectedCallback() {
this.innerHTML = 'Click me!';
}
}
window.customElements.define('click-counter', ClickCounter);
</script>
</head>
<body>
<click-counter></click-counter>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment