1.1.4 • Published 4 years ago
custom-renderer-mixin v1.1.4
custom-renderer-mixin
usage
<script src="node_modules/custom-renderer-mixin/render-mixin.js"></script>
<script>
customElements.define('cu-el', class CuEl extends RenderMixin(HTMLElement) {
get properties() {
return this._properties || {
property: 'hello' // initial property value for first render
}
}
constructor() {
super();
}
connectedCallback() {
super.connectedCallback();
// render after first render...
this.render({property: 'hello hello hello'});
}
get data() {
return [{text: '0'}, {text: '1'}, {text: '2'}, {text: '3'}, {text: '4'}]
}
get template() {
return html`
<p>${'property'}</p>
${this.data.map(i => `<p>${i.text}</p>`)}
`;
}
});
document.querySelector('cu-el').render({property: 'hello hello hello'})
</script>
Features
one way property binding
const property = 'hello';
html`<p>${'property'}</p>`// -> {values: ['hello'], keys= ['property'], strings: ["<p>", "</p>"]}
mapping arrays objects etc..
const data = [0, 1, 2, 3, 4];
html`${data.map(i => `<p>${i}</p>`)}` // -> {strings: ['<p>0</p><p>1</p><p>2</p><p>3</p>'], values: [], keys: []}
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.1.10
6 years ago
0.1.9
6 years ago
0.1.8
6 years ago
0.1.7
6 years ago
0.1.6
6 years ago
0.1.5
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago