Skip to content

Instantly share code, notes, and snippets.

@hectorlorenzo
Created November 15, 2017 11:19
Show Gist options
  • Save hectorlorenzo/efdb7add9d54d553d79236d443517f75 to your computer and use it in GitHub Desktop.
Save hectorlorenzo/efdb7add9d54d553d79236d443517f75 to your computer and use it in GitHub Desktop.
const elemClass = class extends HTMLElement {
constructor() {
super()
}
connectedCallback () {
const o = this
const data = o.options.data
Object.keys(data).forEach((key) => {
Object.defineProperty(o, key, {
enumerable: true,
configurable: true,
get () {
return o.getAttribute(key)
},
set (val) {
o.setAttribute(key, val)
}
})
o[key] = data[key]
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment