-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathHtmlFragment.njs
More file actions
57 lines (49 loc) · 1.25 KB
/
HtmlFragment.njs
File metadata and controls
57 lines (49 loc) · 1.25 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Nullstack from 'nullstack'
class HtmlFragment extends Nullstack {
count = 0
visible = false
objected = false
increment() {
this.count++
}
reveal() {
this.visible = !this.visible
}
countDataKeys({ data }) {
this.hasDataKeys = Object.keys(data).length > 0
}
render() {
return (
<div data-html-parent>
<html
data-chars="a"
onclick={[this.increment, this.countDataKeys, { objected: true }]}
data-count={this.count}
class={['class-one', 'class-two', false]}
style="background-color: black;"
data-keys={this.hasDataKeys}
data-hydrated={this.hydrated}
>
<html
data-chars="b"
data-numbers="0"
data-count={this.count}
onclick={this.reveal}
class="class-three class-four"
style="color: white;"
data-objected={this.objected}
>
HtmlFragment
</html>
{this.visible && (
<html data-visible data-has-visible={this.hasDataVisible}>
HtmlFragment2
</html>
)}
<a href="/" data-html-child>home</a>
</html>
</div>
)
}
}
export default HtmlFragment