Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class Component extends HTMLElement {
  2. constructor() {
  3. super()
  4. this.onclick = event => this.click(event)
  5. this.props = this.getProps()
  6.  
  7. for(let prop in this.props) {
  8. if(this.hasAttribute(prop)) {
  9. this.props[prop] = this.getAttribute(prop)
  10. }
  11. }
  12. let shadowRoot = this.attachShadow({mode: 'open'})
  13. this.update()
  14. }
  15.  
  16. setProp(name, value) {
  17. this.setAttribute(name, value)
  18. }
  19.  
  20. attributeChangedCallback(name, oldValue, newValue) {
  21. this[`${name}Changed`] && this[`${name}Changed`](oldValue, newValue)
  22. this.props[name] = newValue
  23. this.update()
  24. }
  25.  
  26. update() {
  27. this.shadowRoot.innerHTML = this.render()
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement