blob: 03c5355d21d4a5ed3ae52f6cd7536d1c83a7080a (
plain)
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
26
27
28
29
30
31
32
33
34
|
export { ComponentDescription }
import { VEvent } from '../vevent'
import { ComponentVEvent } from './vevent'
/*
<vevent-description />
*/
class ComponentDescription extends ComponentVEvent {
constructor() {
super();
}
redraw(data: VEvent) {
// update ourselves from template
let body = (this.template.content.cloneNode(true) as DocumentFragment).firstElementChild!;
for (let el of body.querySelectorAll('[data-property]')) {
if (!(el instanceof HTMLElement)) continue;
let p = el.dataset.property!;
let d, fmt;
if ((d = data.getProperty(p))) {
if ((fmt = el.dataset.fmt)) {
el.textContent = d.format(fmt);
} else {
el.textContent = d;
}
}
}
this.replaceChildren(body);
}
}
|