Created
June 5, 2019 06:23
-
-
Save annibuliful/a329f0d8170d6a480f97d04fc4853b8d 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
| const templateItem = document.createElement('template'); | |
| templateItem.innerHTML = ` | |
| <div> | |
| <h1></h1> | |
| </div> | |
| `; | |
| class TodoApp extends HTMLElement { | |
| constructor() { | |
| super(); | |
| this._shadowRoot = this.attachShadow({ 'mode': 'open' }); | |
| this._shadowRoot.appendChild(templateItem.content.cloneNode(true)); | |
| this.displayName = this._shadowRoot.querySelector('h1'); | |
| this.displayName.innerText = "test" | |
| } | |
| attributeChangedCallback(name, oldValue, newValue) { | |
| console.log(this.name) | |
| this.displayName.innerText = this.name; | |
| } | |
| static get observedAttributes() { | |
| return ['name']; | |
| } | |
| get name() { | |
| return this.getAttribute('name'); | |
| } | |
| set name(newValue) { | |
| console.log(newValue) | |
| this.setAttribute('name', newValue); | |
| } | |
| } | |
| window.customElements.define('web-card', TodoApp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment