-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
41 lines (33 loc) · 933 Bytes
/
main.js
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
35
36
37
38
39
40
41
import { reactive, customElement, html } from 'pwc';
@customElement('child-element')
class ChildElement extends HTMLElement {
@reactive
accessor data = { foo: 0 }
get template() {
console.log('>>>');
return html`<div>${this.data.foo}</div>`;
}
}
@customElement('custom-element')
class CustomElement extends HTMLElement {
@reactive
accessor #condition = true;
@reactive
accessor #icon = '';
@reactive
accessor #data = { foo: 1 }
handleClick() {
console.log('click');
this.#condition = !this.#condition;
this.#icon += '!';
}
get template() {
const result = html`<div>
<p @click=${this.handleClick}>Condition is ${this.#condition + ''}</p>
${this.#condition ? html`<p>True Condition${this.#icon}</p>` : html`<p>False Condition${this.#icon}</p>`}
<child-element data=${this.#data}></child-element>
</div>`;
console.log(result);
return result;
}
}