1
0
mirror of https://codeberg.org/setop/elm-scripting synced 2025-11-08 21:49:57 +00:00

feat: handle innerHTML

This commit is contained in:
2025-10-05 01:39:20 +02:00
parent c68a679450
commit 0758e1e9b4

9
dom.js
View File

@@ -2,7 +2,6 @@ function Node(parent, tag) {
this.parentNode = parent; // Node
this.pos = 0; // position in siblings list
this.tagName = tag;
this.text = null;
// attributes are stored directly on the node object
// see https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L511
this.children = []; // List of Node
@@ -17,10 +16,14 @@ function Node(parent, tag) {
node.pos = this.children.push(node);
}
this.dump = (d=0) => {
if (this.text != null) {
if (this.text) {
print(this.text);
return
}
if (this.innerHTML) {
print(this.innerHTML);
return
}
std.printf("<%s", this.tagName)
// Set.difference(other) is not avalable in qjs
for (a of Object.keys(this)) {
@@ -53,6 +56,8 @@ document.getElementById = (_id) => { return target}
document.createElement = (tag) => new Node(null, tag);
document.createTextNode = (text) => { t = new Node(null, "#text" ); t.text = text; return t }
var global = {};
try {
// here will come the Elm app code