-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.js
34 lines (34 loc) · 1.5 KB
/
todo.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
window.addEventListener("load", function() {
Scheme.load_main("todo.wasm", {}, {
document: {
body() { return document.body; },
getElementById: Document.prototype.getElementById.bind(document),
createElement: Document.prototype.createElement.bind(document),
createTextNode: Document.prototype.createTextNode.bind(document),
createTreeWalker: Document.prototype.createTreeWalker.bind(document)
},
element: {
value(elem) { return elem.value; },
setValue(elem, value) { elem.value = value; },
checked(elem) { return elem.checked; },
setChecked(elem, checked) { elem.checked = (checked == 1); },
setAttribute(elem, name, value) { elem.setAttribute(name, value); },
removeAttribute(elem, name) { elem.removeAttribute(name); },
appendChild(parent, child) { return parent.appendChild(child); },
remove(elem) { elem.remove(); },
replaceWith(oldElem, newElem) { oldElem.replaceWith(newElem); },
addEventListener(elem, name, f) { elem.addEventListener(name, f); },
removeEventListener(elem, name, f) { elem.removeEventListener(name, f); }
},
event: {
target(event) { return event.target; }
},
treeWalker: {
currentNode(walker) { return walker.currentNode; },
setCurrentNode(walker, node) { walker.currentNode = node; },
nextNode(walker) { return walker.nextNode(); },
firstChild(walker) { return walker.firstChild(); },
nextSibling(walker) { return walker.nextSibling(); }
}
});
});