Created
August 28, 2017 21:53
-
-
Save drufball/f31176380109e83766706f9eea904881 to your computer and use it in GitHub Desktop.
Combining lit-html with Polymer3
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
import { render as litRender } from 'lit-html/lit-html.js' | |
export const LitMixin = (superClass) => class extends superClass{ | |
static get properties() { return {} } | |
static get observers() { | |
const props = Object.keys(this.properties) | |
if( props.length == 0 ) { return [] } | |
return [`_litUpdate(${props.join(",")})`] | |
} | |
static get template() { | |
return ` | |
<div id="root"></div> | |
`; | |
} | |
connectedCallback() { | |
super.connectedCallback(); | |
const props = Object.keys(this.constructor.properties); | |
if( props.length != 0 ) { | |
this._createMethodObserver(this.constructor.observers[0], true); | |
} | |
this._litUpdate() | |
} | |
_litUpdate() { | |
litRender(this.render(), this.$.root); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment