Skip to content

Instantly share code, notes, and snippets.

@annibuliful
Created June 5, 2019 06:23
Show Gist options
  • Select an option

  • Save annibuliful/a329f0d8170d6a480f97d04fc4853b8d to your computer and use it in GitHub Desktop.

Select an option

Save annibuliful/a329f0d8170d6a480f97d04fc4853b8d to your computer and use it in GitHub Desktop.
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