Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
pannous committed Dec 2, 2024
1 parent 315af07 commit 7bfa05f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion docs/wasp.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ function terminate() {

function createHtml(parent, innerHtml) { // via emitHtml
let element = document.createElement("div"); // todo tag
element.innerHTML = chars(innerHtml, app.memory);
let tagOrHtml = chars(innerHtml, app.memory);
if(tagOrHtml[0]=="<") element=document.createElement(tagOrHtml.replace("<","").replace(">",""))
else element.innerHTML = tagOrHtml;
if (!parent) parent = document.body;
else console.log("GOT PARENT", parent, "FOR", element.innerHTML)
parent.appendChild(element);
return element;
}
Expand Down
7 changes: 3 additions & 4 deletions source/wasm_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,14 @@ Code emitHtml(Node &node, Function &function, ExternRef parent = 0) {
if (node.name == "html") {
for (auto &child: node)
code.add(emitHtml(child, function, parent));// html is not parent
// printf("emitHtml node %s", node.serialize().data);
printf("emitHtml code %d", code.length);
return code;
}
if (parent == previous);// use previous return as parent (on stack)
else if (parent)code.add(emitData(*new Node(parent), function));
else code.add(emitCall(*new Node("getDocumentBody"), function));
// code.add(get_local);
// code.addInt(function.locals["parent"].position);
// emitGetter(node, *new Node("appendChild"), function);
// else code.addConst32(0); // get document body in js
if (node.kind == strings)
code.add(emitString(node, function));
Expand All @@ -583,8 +584,6 @@ Code emitHtml(Node &node, Function &function, ExternRef parent = 0) {
for (auto &child: node) {
code.add(emitHtml(child, function, previous));// html is not parent
}
printf("emitHtml code %d", code.length);
// printf("emitHtml node %s", node.serialize().data);
return code;
}

Expand Down

0 comments on commit 7bfa05f

Please sign in to comment.