-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpl-repeat.js
More file actions
25 lines (22 loc) · 820 Bytes
/
pl-repeat.js
File metadata and controls
25 lines (22 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {PlElement, TemplateInstance, html} from "polylib";
class PlRepeat extends PlElement {
static get properties() {
return {
as: { value: 'item' },
sTpl: { type: Object }
}
}
static repTpl = html`<template d:repeat="{{items}}" d:as="[[as]]">[[sTpl]]</template>`;
constructor() {
super({ lightDom: true });
}
connectedCallback() {
super.connectedCallback();
console.log('deprecated pl-repeat')
let tplEl = [...this.childNodes].find( n => n.nodeType === document.COMMENT_NODE && n.textContent.startsWith('tpl:'));
this.sTpl = tplEl?._tpl;
this._ti = new TemplateInstance(PlRepeat.repTpl);
this._ti.attach(null, this, [this, ...tplEl._hctx]);
}
}
customElements.define('pl-repeat', PlRepeat);