-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
75 lines (70 loc) · 2.22 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" src="/src/index.js"></script>
</head>
<body>
<div class="open">Foo</div>
<button
type="button"
onclick="var p = document.createElement('p'); p.textContent = '1234'; document.getElementById('more').appendChild(p)"
>
Add paragraph
</button>
<button
type="button"
onclick="var p = document.querySelector('p'); p.parentElement.removeChild(p);"
>
Remove paragraph
</button>
<button type="button" onclick="addNested()">Add nested button</button>
<p>oh my</p>
<div id="more"></div>
<script>
window.addEventListener("DOMContentLoaded", (event) => {
function addNested() {
const div = document.createElement("div");
const p = document.createElement("p");
const button = document.createElement("button");
button.textContent = "A new button";
button.dataset.button = "blah blah";
p.appendChild(button);
div.appendChild(p);
document.body.appendChild(div);
}
iripo.in("p", function (elem) {
elem.dataset.foo = "bar";
});
iripo.in("p", function (elem) {
elem.dataset.time = Date.now();
console.log(elem, "has been added");
});
iripo.out("p", function (elem) {
console.log(elem, "has been removed");
});
iripo.in("p", function (elem) {
elem.dataset.time = Date.now();
});
iripo.in("p", function (elem) {
elem.onclick = function () {
alert(1);
};
});
iripo.in("[data-button]", function (elem) {
console.log(elem, "has been added");
});
iripo.in("div.open", function (elem) {
console.log(elem, "DIV.open has been added");
});
iripo.out("div.open", function (elem) {
console.log(elem, "DIV.open has been removed");
});
window.addNested = addNested;
});
</script>
</body>
</html>