diff options
author | David Thompson <dthompson2@worcester.edu> | 2024-07-06 18:08:46 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2024-07-06 18:08:46 -0400 |
commit | 23311804da2d59b6e63645c63ea5020599349cba (patch) | |
tree | 21f95871e22fe12a6cb68ad68658b46e3e5d91d2 /chapter-7/propagators.js | |
parent | be39f9f57fa1ddb5b1d161f1ef9a69bd9cf8630f (diff) |
More tweaks to propagator prototype.
Diffstat (limited to 'chapter-7/propagators.js')
-rw-r--r-- | chapter-7/propagators.js | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/chapter-7/propagators.js b/chapter-7/propagators.js index c392ad1..fe0034a 100644 --- a/chapter-7/propagators.js +++ b/chapter-7/propagators.js @@ -1,23 +1,30 @@ 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) - }, + try { + 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) + }, + } + }); + } catch(e) { + if(e instanceof WebAssembly.CompileError) { + document.getElementById("wasm-error").hidden = false; } - }); + throw e; + } }); |