Created
November 9, 2016 19:21
-
-
Save sindrenm/75e998f4c98562b3ed34cf257db70d6e to your computer and use it in GitHub Desktop.
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> | |
<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