Created
November 3, 2016 21:56
-
-
Save robdodson/12ee1ae2bb7e051790038b86d4fe3b23 to your computer and use it in GitHub Desktop.
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
| export default class XFoo extends HTMLElement { | |
| message: string; | |
| constructor() { | |
| super(); | |
| } | |
| connectedCallback() { | |
| this.innerHTML = `<p>${this.message}</p>`; | |
| this.addEventListener('click', this.onClick); | |
| } | |
| onClick(e: Event) { | |
| this.innerHTML = `<p>I was clicked!</p>`; | |
| this.dispatchEvent(new CustomEvent('x-foo-changed', { detail: { foo: 'bar' } })); | |
| } | |
| } | |
| window.customElements.define('x-foo', XFoo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment