Skip to content

Instantly share code, notes, and snippets.

@ilopX
Last active November 28, 2019 12:33
Show Gist options
  • Save ilopX/74a7e8b5b3bee5e6d03c5b0d7b8b79ef to your computer and use it in GitHub Desktop.
Save ilopX/74a7e8b5b3bee5e6d03c5b0d7b8b79ef to your computer and use it in GitHub Desktop.
export default function module() {
class Component {
/**
*
* @param {HTMLElement} anchor
*/
constructor(anchor) {
this._anchor = anchor
this._props = {}
// this._renderView()
}
onInit() {}
onPropsChanges() { }
set props(value) {
this._props = value
this.onPropsChanges(this._props)
this._renderView()
}
get props() {
return { ...this._props }
}
// set anchor(element) {
// this._anchor = element
// this._renderView()
// }
get anchor() {
return this._anchor
}
_renderView() {
if (this._anchor) {
this._anchor.innerHTML = this.render()
}
}
render() {
return ''
}
}
return {
Component
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment