summaryrefslogtreecommitdiff
path: root/chapter-7/propagators.js
blob: c392ad11061e7cca104200890f15633ec0fa46f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
window.addEventListener("load", async () => {
  await Scheme.load_main("propagators.wasm", {
    reflect_wasm_dir: "hoot",
    user_imports: {
      window: {
        setTimeout: setTimeout
      },
      document: {
        makeTextNode: Document.prototype.createTextNode.bind(document),
        makeElement: Document.prototype.createElement.bind(document),
        body: () => document.body,
      },
      element: {
        appendChild: (parent, child) => parent.appendChild(child),
        setAttribute: (elem, attr, value) => elem.setAttribute(attr, value),
        getValue: (elem) => elem.value,
        setValue: (elem, val) => elem.value = val,
        replaceWith: (oldElem, newElem) => oldElem.replaceWith(newElem),
        addEventListener: (elem, name, f) => elem.addEventListener(name, f)
      },
    }
  });
});