-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathAnchorModifiers.njs
More file actions
62 lines (52 loc) · 1.35 KB
/
AnchorModifiers.njs
File metadata and controls
62 lines (52 loc) · 1.35 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
58
59
60
61
62
import Nullstack from 'nullstack'
class AnchorModifiers extends Nullstack {
html = `
<a href="/anchor-modifiers?source=html">html</a>
`
count = 0
objected = false
updated = false
hydrate() {
this._element.querySelector('a').addEventListener('click', () => {
this.clickedHTML = true
})
}
clickJSX() {
this.clickedJSX = true
}
markAsUpdated() {
document.body.dataset.updated = true
}
increment() {
this.count++
}
render() {
return (
<div
ref={this._element}
data-clicked-jsx={this.clickedJSX}
data-clicked-html={this.clickedHTML}
data-count={this.count}
data-objected={this.objected}
data-updated={this.updated}
data-hydrated={this.hydrated}
>
<div html={this.html} />
<button onclick={this.markAsUpdated}> update </button>
<a href="/anchor-modifiers?source=jsx" onclick={this.clickJSX}>
jsx
</a>
<a href="/anchor-modifiers?source=incremented" onclick={this.increment}>
increment
</a>
<a href="/anchor-modifiers?source=object" onclick={{ objected: true }}>
object
</a>
<a href="/anchor-modifiers?source=array" onclick={[this.increment, { objected: true }]}>
array
</a>
</div>
)
}
}
export default AnchorModifiers