-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
88 lines (78 loc) · 1.99 KB
/
index.html
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test 'html-tag-js'</title>
<script src="./dist/Ref.js"></script>
<script src="./dist/tag.js"></script>
</head>
<body>
<h1>HTML-TAG-JS</h1>
<div id="app"></div>
<script>
const p = new Ref();
p.onref = () => {
console.log(p.el.children[0]);
};
p.style.display = 'block';
p.style.color = 'red';
p.style.width = '100px';
p.style.height = '100px';
app.append(
tag('button', {
textContent: 'This is a button',
onclick: () => {
p.textContent = 'The button was clicked';
},
}),
tag('p', {
ref: p,
textContent: 'This is a paragraph',
attr: {
data: undefined,
},
children: [
tag('span', {
textContent: 'This is a span',
}),
['\nThis is a text'],
['\nAnother text'],
],
}),
tag('span', {
children: [null, undefined, tag.text('This is a span'), tag('br')],
}),
);
const text = tag.use('text');
app.append(
tag('p', {
children: [
tag('div', {
textContent: text,
}),
tag('br'),
...Array(10000)
.fill(null)
.map(() => text),
tag('button', {
textContent: 'Click me',
onclick: () => {
text.value = 'The button was clicked';
},
}),
],
}),
);
text.onChange = (value) => {
console.log(value);
};
console.log({ text });
p.style.backgroundColor = 'blue';
p.onref = (ref) => {
console.log(ref);
};
</script>
</body>
</html>